Nuke 17 useless files (#1653)

All files deleted and disabled were either:

Not touched for 2+ years
Replaced with native DM functions (JSON specifically)
Generally replaced with newer iterations
This commit is contained in:
skull132
2017-01-29 21:45:11 +02:00
committed by GitHub
parent b1b4ce00a8
commit 5909bf65ba
20 changed files with 3 additions and 2311 deletions
-3
View File
@@ -1615,9 +1615,6 @@
#include "code\modules\multiz\pipes.dm"
#include "code\modules\multiz\structures.dm"
#include "code\modules\multiz\turf.dm"
#include "code\modules\nano\_JSON.dm"
#include "code\modules\nano\JSON Reader.dm"
#include "code\modules\nano\JSON Writer.dm"
#include "code\modules\nano\nanoexternal.dm"
#include "code\modules\nano\nanomanager.dm"
#include "code\modules\nano\nanomapgen.dm"
-26
View File
@@ -1,26 +0,0 @@
/matrix/proc/TurnTo(old_angle, new_angle)
. = new_angle - old_angle
Turn(.) //BYOND handles cases such as -270, 360, 540 etc. DOES NOT HANDLE 180 TURNS WELL, THEY TWEEN AND LOOK LIKE SHIT
/atom/proc/SpinAnimation(speed = 10, loops = -1, clockwise = 1, segments = 3)
if(!segments)
return
var/segment = 360/segments
if(!clockwise)
segment = -segment
var/list/matrices = list()
for(var/i in 1 to segments-1)
var/matrix/M = matrix(transform)
M.Turn(segment*i)
matrices += M
var/matrix/last = matrix(transform)
matrices += last
speed /= segments
animate(src, transform = matrices[1], time = speed, loops)
for(var/i in 2 to segments) //2 because 1 is covered above
animate(transform = matrices[i], time = speed)
//doesn't have an object argument because this is "Stacking" with the animate call above
//3 billion% intentional
-376
View File
@@ -1,376 +0,0 @@
/atom/DblClick(location, control, params) //TODO: DEFERRED: REWRITE
if(!usr) return
// ------- TIME SINCE LAST CLICK -------
if (world.time <= usr:lastDblClick+1)
return
else
usr:lastDblClick = world.time
//Putting it here for now. It diverts stuff to the mech clicking procs. Putting it here stops us drilling items in our inventory Carn
if(istype(usr.loc,/obj/mecha))
if(usr.client && (src in usr.client.screen))
return
var/obj/mecha/Mech = usr.loc
Mech.click_action(src,usr)
return
// ------- DIR CHANGING WHEN CLICKING ------
if( iscarbon(usr) && !usr.buckled )
if( src.x && src.y && usr.x && usr.y )
var/dx = src.x - usr.x
var/dy = src.y - usr.y
if(dy || dx)
if(abs(dx) < abs(dy))
if(dy > 0) usr.set_dir(NORTH)
else usr.set_dir(SOUTH)
else
if(dx > 0) usr.set_dir(EAST)
else usr.set_dir(WEST)
else
if(pixel_y > 16) usr.set_dir(NORTH)
else if(pixel_y < -16) usr.set_dir(SOUTH)
else if(pixel_x > 16) usr.set_dir(EAST)
else if(pixel_x < -16) usr.set_dir(WEST)
// ------- AI -------
else if (istype(usr, /mob/living/silicon/ai))
var/mob/living/silicon/ai/ai = usr
if (ai.control_disabled)
return
// ------- CYBORG -------
else if (istype(usr, /mob/living/silicon/robot))
var/mob/living/silicon/robot/bot = usr
if (bot.lockcharge) return
..()
// ------- SHIFT-CLICK -------
if(params)
var/parameters = params2list(params)
if(parameters["shift"]){
if(!isAI(usr))
ShiftClick(usr)
else
AIShiftClick(usr)
return
}
// ------- ALT-CLICK -------
if(parameters["alt"]){
if(!isAI(usr))
AltClick(usr)
else
AIAltClick(usr)
return
}
// ------- CTRL-CLICK -------
if(parameters["ctrl"]){
if(!isAI(usr))
CtrlClick(usr)
else
AICtrlClick(usr)
return
}
// ------- MIDDLE-CLICK -------
if(parameters["middle"]){
if(!isAI(usr))
MiddleClick(usr)
return
}
// ------- THROW -------
if(usr.in_throw_mode)
return usr:throw_item(src)
// ------- ITEM IN HAND DEFINED -------
var/obj/item/W = usr.get_active_hand()
/* Now handled by get_active_hand()
// ------- ROBOT -------
if(istype(usr, /mob/living/silicon/robot))
if(!isnull(usr:module_active))
W = usr:module_active
else
W = null
*/
// ------- ATTACK SELF -------
if (W == src && usr.stat == 0)
W.attack_self(usr)
if(usr.hand)
usr.update_inv_l_hand(0) //update in-hand overlays
else
usr.update_inv_r_hand(0)
return
// ------- PARALYSIS, STUN, WEAKENED, DEAD, (And not AI) -------
if (((usr.paralysis || usr.stunned || usr.weakened) && !istype(usr, /mob/living/silicon/ai)) || usr.stat != 0)
return
// ------- CLICKING STUFF IN CONTAINERS -------
if ((!( src in usr.contents ) && (((!( isturf(src) ) && (!( isturf(src.loc) ) && (src.loc && !( isturf(src.loc.loc) )))) || !( isturf(usr.loc) )) && (src.loc != usr.loc && (!( istype(src, /obj/screen) ) && !( usr.contents.Find(src.loc) ))))))
if (istype(usr, /mob/living/silicon/ai))
var/mob/living/silicon/ai/ai = usr
if (ai.control_disabled)
return
else
return
// ------- 1 TILE AWAY -------
var/t5
// ------- AI CAN CLICK ANYTHING -------
if(istype(usr, /mob/living/silicon/ai))
t5 = 1
// ------- CYBORG CAN CLICK ANYTHING WHEN NOT HOLDING STUFF -------
else if(istype(usr, /mob/living/silicon/robot) && !W)
t5 = 1
else
t5 = in_range(src, usr) || src.loc == usr
// world << "according to dblclick(), t5 is [t5]"
// ------- ACTUALLY DETERMINING STUFF -------
if (((t5 || (W && (W.flags & USEDELAY))) && !( istype(src, /obj/screen) )))
// ------- ( CAN USE ITEM OR HAS 1 SECOND USE DELAY ) AND NOT CLICKING ON SCREEN -------
if (usr.next_move < world.time)
usr.prev_move = usr.next_move
usr.next_move = world.time + 10
else
// ------- ALREADY USED ONE ITEM WITH USE DELAY IN THE PREVIOUS SECOND -------
return
// ------- DELAY CHECK PASSED -------
if ((src.loc && (get_dist(src, usr) < 2 || src.loc == usr.loc)))
// ------- CLICKED OBJECT EXISTS IN GAME WORLD, DISTANCE FROM PERSON TO OBJECT IS 1 SQUARE OR THEY'RE ON THE SAME SQUARE -------
var/direct = get_dir(usr, src)
var/obj/item/weapon/dummy/D = new /obj/item/weapon/dummy( usr.loc )
var/ok = 0
if ( (direct - 1) & direct)
// ------- CLICKED OBJECT IS LOCATED IN A DIAGONAL POSITION FROM THE PERSON -------
var/turf/Step_1
var/turf/Step_2
switch(direct)
if(5.0)
Step_1 = get_step(usr, NORTH)
Step_2 = get_step(usr, EAST)
if(6.0)
Step_1 = get_step(usr, SOUTH)
Step_2 = get_step(usr, EAST)
if(9.0)
Step_1 = get_step(usr, NORTH)
Step_2 = get_step(usr, WEST)
if(10.0)
Step_1 = get_step(usr, SOUTH)
Step_2 = get_step(usr, WEST)
else
if(Step_1 && Step_2)
// ------- BOTH CARDINAL DIRECTIONS OF THE DIAGONAL EXIST IN THE GAME WORLD -------
var/check_1 = 0
var/check_2 = 0
if(step_to(D, Step_1))
check_1 = 1
for(var/obj/border_obstacle in Step_1)
if(border_obstacle.flags & ON_BORDER)
if(!border_obstacle.CheckExit(D, src))
check_1 = 0
// ------- YOU TRIED TO CLICK ON AN ITEM THROUGH A WINDOW (OR SIMILAR THING THAT LIMITS ON BORDERS) ON ONE OF THE DIRECITON TILES -------
for(var/obj/border_obstacle in get_turf(src))
if((border_obstacle.flags & ON_BORDER) && (src != border_obstacle))
if(!border_obstacle.CanPass(D, D.loc, 1, 0))
// ------- YOU TRIED TO CLICK ON AN ITEM THROUGH A WINDOW (OR SIMILAR THING THAT LIMITS ON BORDERS) ON THE TILE YOU'RE ON -------
check_1 = 0
D.loc = usr.loc
if(step_to(D, Step_2))
check_2 = 1
for(var/obj/border_obstacle in Step_2)
if(border_obstacle.flags & ON_BORDER)
if(!border_obstacle.CheckExit(D, src))
check_2 = 0
for(var/obj/border_obstacle in get_turf(src))
if((border_obstacle.flags & ON_BORDER) && (src != border_obstacle))
if(!border_obstacle.CanPass(D, D.loc, 1, 0))
check_2 = 0
if(check_1 || check_2)
ok = 1
// ------- YOU CAN REACH THE ITEM THROUGH AT LEAST ONE OF THE TWO DIRECTIONS. GOOD. -------
/*
More info:
If you're trying to click an item in the north-east of your mob, the above section of code will first check if tehre's a tile to the north or you and to the east of you
These two tiles are Step_1 and Step_2. After this, a new dummy object is created on your location. It then tries to move to Step_1, If it succeeds, objects on the turf you're on and
the turf that Step_1 is are checked for items which have the ON_BORDER flag set. These are itmes which limit you on only one tile border. Windows, for the most part.
CheckExit() and CanPass() are use to determine this. The dummy object is then moved back to your location and it tries to move to Step_2. Same checks are performed here.
If at least one of the two checks succeeds, it means you can reach the item and ok is set to 1.
*/
else
// ------- OBJECT IS ON A CARDINAL TILE (NORTH, SOUTH, EAST OR WEST OR THE TILE YOU'RE ON) -------
if(loc == usr.loc)
ok = 1
// ------- OBJECT IS ON THE SAME TILE AS YOU -------
else
ok = 1
//Now, check objects to block exit that are on the border
for(var/obj/border_obstacle in usr.loc)
if(border_obstacle.flags & ON_BORDER)
if(!border_obstacle.CheckExit(D, src))
ok = 0
//Next, check objects to block entry that are on the border
for(var/obj/border_obstacle in get_turf(src))
if((border_obstacle.flags & ON_BORDER) && (src != border_obstacle))
if(!border_obstacle.CanPass(D, D.loc, 1, 0))
ok = 0
/*
See the previous More info, for... more info...
*/
//qdel(D)
// Garbage Collect Dummy
D.loc = null
D = null
// ------- DUMMY OBJECT'S SERVED IT'S PURPOSE, IT'S REWARDED WITH A SWIFT DELETE -------
if (!( ok ))
// ------- TESTS ABOVE DETERMINED YOU CANNOT REACH THE TILE -------
return 0
if (!( usr.restrained() || (usr.lying && usr.buckled!=src) ))
// ------- YOU ARE NOT REASTRAINED -------
if (W)
// ------- YOU HAVE AN ITEM IN YOUR HAND - HANDLE ATTACKBY AND AFTERATTACK -------
var/ignoreAA = 0 //Ignore afterattack(). Surgery uses this.
if (t5)
ignoreAA = src.attackby(W, usr)
if (W && !ignoreAA)
W.afterattack(src, usr, (t5 ? 1 : 0), params)
else
// ------- YOU DO NOT HAVE AN ITEM IN YOUR HAND -------
if (istype(usr, /mob/living/carbon/human))
// ------- YOU ARE HUMAN -------
src.attack_hand(usr, usr.hand)
else
// ------- YOU ARE NOT HUMAN. WHAT ARE YOU - DETERMINED HERE AND PROPER ATTACK_MOBTYPE CALLED -------
if (istype(usr, /mob/living/carbon/monkey))
src.attack_paw(usr, usr.hand)
else if (istype(usr, /mob/living/carbon/alien/humanoid))
if(usr.m_intent == "walk" && istype(usr, /mob/living/carbon/alien/humanoid/hunter))
usr.m_intent = "run"
usr.hud_used.move_intent.icon_state = "running"
usr.update_icons()
src.attack_alien(usr, usr.hand)
else if (istype(usr, /mob/living/carbon/alien/larva))
src.attack_larva(usr)
else if (istype(usr, /mob/living/silicon/ai) || istype(usr, /mob/living/silicon/robot))
src.attack_ai(usr, usr.hand)
else if(istype(usr, /mob/living/carbon/slime))
src.attack_slime(usr)
else if(istype(usr, /mob/living/simple_animal))
src.attack_animal(usr)
else
// ------- YOU ARE RESTRAINED. DETERMINE WHAT YOU ARE AND ATTACK WITH THE PROPER HAND_X PROC -------
if (istype(usr, /mob/living/carbon/human))
src.hand_h(usr, usr.hand)
else if (istype(usr, /mob/living/carbon/monkey))
src.hand_p(usr, usr.hand)
else if (istype(usr, /mob/living/carbon/alien/humanoid))
src.hand_al(usr, usr.hand)
else if (istype(usr, /mob/living/silicon/ai) || istype(usr, /mob/living/silicon/robot))
src.hand_a(usr, usr.hand)
else
// ------- ITEM INACESSIBLE OR CLICKING ON SCREEN -------
if (istype(src, /obj/screen))
// ------- IT'S THE HUD YOU'RE CLICKING ON -------
usr.prev_move = usr.next_move
usr:lastDblClick = world.time + 2
if (usr.next_move < world.time)
usr.next_move = world.time + 2
else
return
// ------- 2 DECISECOND DELAY FOR CLICKING PASSED -------
if (!( usr.restrained() ))
// ------- YOU ARE NOT RESTRAINED -------
if ((W && !( istype(src, /obj/screen) )))
// ------- IT SHOULD NEVER GET TO HERE, DUE TO THE ISTYPE(SRC, /OBJ/SCREEN) FROM PREVIOUS IF-S - I TESTED IT WITH A DEBUG OUTPUT AND I COULDN'T GET THIST TO SHOW UP. -------
src.attackby(W, usr)
if (W)
W.afterattack(src, usr,, params)
else
// ------- YOU ARE NOT RESTRAINED, AND ARE CLICKING A HUD OBJECT -------
if (istype(usr, /mob/living/carbon/human))
src.attack_hand(usr, usr.hand)
else if (istype(usr, /mob/living/carbon/monkey))
src.attack_paw(usr, usr.hand)
else if (istype(usr, /mob/living/carbon/alien/humanoid))
src.attack_alien(usr, usr.hand)
else
// ------- YOU ARE RESTRAINED CLICKING ON A HUD OBJECT -------
if (istype(usr, /mob/living/carbon/human))
src.hand_h(usr, usr.hand)
else if (istype(usr, /mob/living/carbon/monkey))
src.hand_p(usr, usr.hand)
else if (istype(usr, /mob/living/carbon/alien/humanoid))
src.hand_al(usr, usr.hand)
else
// ------- YOU ARE CLICKING ON AN OBJECT THAT'S INACCESSIBLE TO YOU AND IS NOT YOUR HUD -------
if((LASER in usr:mutations) && usr:a_intent == I_HURT && world.time >= usr.next_move)
// ------- YOU HAVE THE LASER MUTATION, YOUR INTENT SET TO HURT AND IT'S BEEN MORE THAN A DECISECOND SINCE YOU LAS TATTACKED -------
var/turf/T = get_turf(usr)
var/turf/U = get_turf(src)
if(istype(usr, /mob/living/carbon/human))
usr:nutrition -= rand(1,5)
usr:handle_regular_hud_updates()
var/obj/item/projectile/beam/A = new /obj/item/projectile/beam( usr.loc )
A.icon = 'icons/effects/genetics.dmi'
A.icon_state = "eyelasers"
playsound(usr.loc, 'sound/weapons/taser2.ogg', 75, 1)
A.firer = usr
A.def_zone = usr:get_organ_target()
A.original = src
A.current = T
A.yo = U.y - T.y
A.xo = U.x - T.x
spawn( 1 )
A.process()
usr.next_move = world.time + 6
return
-94
View File
@@ -1,94 +0,0 @@
var/global/datum/news_controller/news_controller
/datum/news_controller
var/count = 0 //Count of articles pulled and published
var/publish_time //Ingame time for when the stored article is to be published
var/article_id //Stored article's primary-key
var/running = 1 //Boolean value, self-explanitory
var/fails = 0 //Counter for failed queries
var/max_fails = 5 //Maximum amount of failures before the controller is killed
/datum/news_controller/proc/process()
if(!running) //Not running, return.
return
if(fails >= max_fails) //Too many failures, killing.
kill()
return
if(!article_id && !publish_time) //No entry stored. Update and get one.
update()
return
if(publish_time < world.time) //Time to publish the article.
publish()
if(fails)
fails = 0
//Stores a new article for publishing.
/datum/news_controller/proc/update()
establish_db_connection(dbcon)
if(!dbcon.IsConnected())
error("SQL database connection failed. News_controller failed to retreive information.")
fails++
return
var/DBQuery/update_query = dbcon.NewQuery("SELECT id, publishtime FROM ss13_news WHERE status = 2 ORDER BY publishtime ASC LIMIT :count, 1")
update_query.Execute(list(":count" = count))
if(update_query.ErrorMsg())
fails++
return
if(!update_query.RowCount())
kill()
return
while(update_query.NextRow())
article_id = text2num(update_query.item[1])
publish_time = text2num(update_query.item[2]) * 600
count++
//Publish the stored article.
/datum/news_controller/proc/publish()
establish_db_connection(dbcon)
if(!dbcon.IsConnected())
error("SQL database connection failed. News_controller failed to retreive information.")
fails++
return
var/DBQuery/publish_query = dbcon.NewQuery("SELECT channel, author, body FROM ss13_news WHERE id = :article_id")
publish_query.Execute(list(":article_id" = article_id))
if(publish_query.ErrorMsg())
fails++
return
var/article_channel
var/article_author
var/article_content
while(publish_query.NextRow())
article_channel = publish_query.item[1]
article_author = publish_query.item[2]
article_content = publish_query.item[3]
var/channel_found
for(var/datum/feed_channel/FC in news_network.network_channels)
if(FC.channel_name == article_channel)
channel_found = 1
break
if(!channel_found)
news_network.CreateFeedChannel(article_channel, article_author, 0)
news_network.SubmitArticle(article_content, article_author, article_channel)
article_id = null
publish_time = null
update()
//Kills the controller.
/datum/news_controller/proc/kill()
running = 0
return
+2 -2
View File
@@ -114,7 +114,7 @@ var/global/ManifestJSON
department = 1
if(depthead && sci.len != 1)
sci.Swap(1,sci.len)
if(real_rank in cargo_positions)
car[++car.len] = list("name" = name, "rank" = rank, "active" = isactive)
department = 1
@@ -146,7 +146,7 @@ var/global/ManifestJSON
"bot" = bot,\
"misc" = misc\
)
ManifestJSON = list2json(PDA_Manifest)
ManifestJSON = json_encode(PDA_Manifest)
return
-128
View File
@@ -1,128 +0,0 @@
/////////////////////////// DNA DATUM
/datum/dna
var/unique_enzymes = null
var/struc_enzymes = null
var/uni_identity = null
var/b_type = "A+"
var/mutantrace = null //The type of mutant race the player is if applicable (i.e. potato-man)
var/real_name //Stores the real name of the person who originally got this dna datum. Used primarely for changelings,
/datum/dna/proc/check_integrity(var/mob/living/carbon/human/character)
if(character)
if(length(uni_identity) != 39)
//Lazy.
var/temp
//Hair
var/hair = 0
if(!character.h_style)
character.h_style = "Skinhead"
var/hrange = round(4095 / hair_styles_list.len)
var/index = hair_styles_list.Find(character.h_style)
if(index)
hair = index * hrange - rand(1,hrange-1)
//Facial Hair
var/beard = 0
if(!character.f_style)
character.f_style = "Shaved"
var/f_hrange = round(4095 / facial_hair_styles_list.len)
index = facial_hair_styles_list.Find(character.f_style)
if(index)
beard = index * f_hrange - rand(1,f_hrange-1)
temp = add_zero2(num2hex((character.r_hair),1), 3)
temp += add_zero2(num2hex((character.b_hair),1), 3)
temp += add_zero2(num2hex((character.g_hair),1), 3)
temp += add_zero2(num2hex((character.r_facial),1), 3)
temp += add_zero2(num2hex((character.b_facial),1), 3)
temp += add_zero2(num2hex((character.g_facial),1), 3)
temp += add_zero2(num2hex(((character.s_tone + 220) * 16),1), 3)
temp += add_zero2(num2hex((character.r_eyes),1), 3)
temp += add_zero2(num2hex((character.g_eyes),1), 3)
temp += add_zero2(num2hex((character.b_eyes),1), 3)
var/gender
if (character.gender == MALE)
gender = add_zero2(num2hex((rand(1,(2050+BLOCKADD))),1), 3)
else
gender = add_zero2(num2hex((rand((2051+BLOCKADD),4094)),1), 3)
temp += gender
temp += add_zero2(num2hex((beard),1), 3)
temp += add_zero2(num2hex((hair),1), 3)
uni_identity = temp
if(length(struc_enzymes)!= 3*STRUCDNASIZE)
var/mutstring = ""
for(var/i = 1, i <= STRUCDNASIZE, i++)
mutstring += add_zero2(num2hex(rand(1,1024)),3)
struc_enzymes = mutstring
if(length(unique_enzymes) != 32)
unique_enzymes = md5(character.real_name)
else
if(length(uni_identity) != 39) uni_identity = "00600200A00E0110148FC01300B0095BD7FD3F4"
if(length(struc_enzymes)!= 3*STRUCDNASIZE) struc_enzymes = "43359156756131E13763334D1C369012032164D4FE4CD61544B6C03F251B6C60A42821D26BA3B0FD6"
/datum/dna/proc/ready_dna(mob/living/carbon/human/character)
var/temp
//Hair
var/hair = 0
if(!character.h_style)
character.h_style = "Bald"
var/hrange = round(4095 / hair_styles_list.len)
var/index = hair_styles_list.Find(character.h_style)
if(index)
hair = index * hrange - rand(1,hrange-1)
//Facial Hair
var/beard = 0
if(!character.f_style)
character.f_style = "Shaved"
var/f_hrange = round(4095 / facial_hair_styles_list.len)
index = facial_hair_styles_list.Find(character.f_style)
if(index)
beard = index * f_hrange - rand(1,f_hrange-1)
temp = add_zero2(num2hex((character.r_hair),1), 3)
temp += add_zero2(num2hex((character.b_hair),1), 3)
temp += add_zero2(num2hex((character.g_hair),1), 3)
temp += add_zero2(num2hex((character.r_facial),1), 3)
temp += add_zero2(num2hex((character.b_facial),1), 3)
temp += add_zero2(num2hex((character.g_facial),1), 3)
temp += add_zero2(num2hex(((character.s_tone + 220) * 16),1), 3)
temp += add_zero2(num2hex((character.r_eyes),1), 3)
temp += add_zero2(num2hex((character.g_eyes),1), 3)
temp += add_zero2(num2hex((character.b_eyes),1), 3)
var/gender
if (character.gender == MALE)
gender = add_zero2(num2hex((rand(1,(2050+BLOCKADD))),1), 3)
else
gender = add_zero2(num2hex((rand((2051+BLOCKADD),4094)),1), 3)
temp += gender
temp += add_zero2(num2hex((beard),1), 3)
temp += add_zero2(num2hex((hair),1), 3)
uni_identity = temp
var/mutstring = ""
for(var/i = 1, i <= STRUCDNASIZE, i++)
mutstring += add_zero2(num2hex(rand(1,1024)),3)
struc_enzymes = mutstring
unique_enzymes = md5(character.real_name)
reg_dna[unique_enzymes] = character.real_name
/////////////////////////// DNA DATUM
-100
View File
@@ -1,100 +0,0 @@
var/jsonpath = "/home/bay12/public_html"
var/dmepath = "/home/bay12/git/baystation12.dme"
var/makejson = 1 //temp
proc/makejson()
if(!makejson)
return
fdel("[jsonpath]/info.json")
//usr << "Error cant delete json"
//else
//usr << "Deleted json in public html"
fdel("info.json")
//usr << "error cant delete local json"
//else
//usr << "Deleted local json"
var/F = file("info.json")
if(!isfile(F))
return
var/mode
if(ticker)
if(ticker.current_state == 1)
mode = "Round Setup"
else if(ticker.hide_mode)
mode = "SECRET"
else
mode = master_mode
var/playerscount = 0
var/players = ""
var/admins = "no"
for(var/client/C)
playerscount++
if(C.holder && C.holder.level >= 0) // make sure retired admins don't make nt think admins are on
if(!C.stealth)
admins = "yes"
players += "[C.key];"
else
players += "[C.fakekey];"
else
players += "[C.key];"
F << "{\"mode\":\"[mode]\",\"players\" : \"[players]\",\"playercount\" : \"[playerscount]\",\"admin\" : \"[admins]\",\"time\" : \"[time2text(world.realtime,"MM/DD - hh:mm")]\"}"
fcopy("info.json","[jsonpath]/info.json")
/proc/switchmap(newmap,newpath)
var/oldmap
var/obj/mapinfo/M = locate()
if(M)
oldmap = M.mapname
else
message_admins("Did not locate mapinfo object. Go bug the mapper to add a /obj/mapinfo to their map!\n For now, you can probably spawn one manually. If you do, be sure to set it's mapname var correctly, or else you'll just get an error again.")
return
message_admins("Current map: [oldmap]")
var/text = file2text(dmepath)
var/path = "#include \"maps/[oldmap].dmm\""
var/xpath = "#include \"maps/[newpath].dmm\""
var/loc = findtext(text,path,1,0)
if(!loc)
path = "#include \"maps\\[oldmap].dmm\""
xpath = "#include \"maps\\[newpath].dmm\""
loc = findtext(text,path,1,0)
if(!loc)
message_admins("Could not find '#include \"maps\\[oldmap].dmm\"' or '\"maps/[oldmap].dmm\"' in the bs12.dme. The mapinfo probably has an incorrect mapname var. Alternatively, could not find the .dme itself, at [dmepath].")
return
var/rest = copytext(text, loc + length(path))
text = copytext(text,1,loc)
text += "\n[xpath]"
text += rest
/* for(var/A in lines)
if(findtext(A,path,1,0))
lineloc = lines.Find(A,1,0)
lines[lineloc] = xpath
world << "FOUND"*/
fdel(dmepath)
var/file = file(dmepath)
file << text
message_admins("Compiling...")
shell("./recompile")
message_admins("Done")
world.Reboot("Switching to [newmap]")
obj/mapinfo
invisibility = 101
var/mapname = "thismap"
var/decks = 4
proc/GetMapInfo()
// var/obj/mapinfo/M = locate()
// Just removing these to try and fix the occasional JSON -> WORLD issue.
// world << M.name
// world << M.mapname
client/proc/ChangeMap(var/X as text)
set name = "Change Map"
set category = "Admin"
switchmap(X,X)
proc/send2adminirc(channel,msg)
world << channel << " "<< msg
shell("python nudge.py '[channel]' [msg]")
-126
View File
@@ -1,126 +0,0 @@
//This file was auto-corrected by findeclaration.exe on 29/05/2012 15:03:04
#define BOOK_VERSION_MIN 1
#define BOOK_VERSION_MAX 2
#define BOOK_PATH "data/books/"
#define BOOKS_USE_SQL 0 // no guarentee for this branch to work right with sql
var/global/datum/book_manager/book_mgr = new()
datum/book_manager/proc/path(id)
if(isnum(id)) // kill any path exploits
return "[BOOK_PATH][id].sav"
datum/book_manager/proc/getall()
var/list/paths = flist(BOOK_PATH)
var/list/books = new()
for(var/path in paths)
var/datum/archived_book/B = new(BOOK_PATH + path)
books += B
return books
datum/book_manager/proc/freeid()
var/list/paths = flist(BOOK_PATH)
var/id = paths.len + 101
// start at 101+number of books, which will be correct id if none have been deleted, etc
// otherwise, keep moving forward until we find an open id
while(fexists(path(id)))
id++
return id
/client/proc/delbook()
set name = "Delete Book"
set desc = "Permamently deletes a book from the database."
set category = "Admin"
if(!src.holder)
src << "Only administrators may use this command."
return
var/isbn = input("ISBN number?", "Delete Book") as num | null
if(!isbn)
return
if(BOOKS_USE_SQL && config.sql_enabled)
var/DBConnection/dbcon = new()
dbcon.Connect("dbi:mysql:[sqldb]:[sqladdress]:[sqlport]","[sqllogin]","[sqlpass]")
if(!dbcon.IsConnected())
alert("Connection to Archive has been severed. Aborting.")
else
var/DBQuery/query = dbcon.NewQuery("DELETE FROM ss13_library WHERE id=[isbn]")
if(!query.Execute())
usr << query.ErrorMsg()
dbcon.Disconnect()
else
book_mgr.remove(isbn)
log_admin("[usr.key] has deleted the book [isbn]")
// delete a book
datum/book_manager/proc/remove(var/id)
fdel(path(id))
datum/archived_book
var/author // Who wrote the thing, can be changed by pen or PC. It is not automatically assigned
var/title // The real name of the book.
var/category // The category/genre of the book
var/id // the id of the book (like an isbn number)
var/dat // Actual page content
var/author_real // author's real_name
var/author_key // author's byond key
var/list/icon/photos // in-game photos used
// loads the book corresponding by the specified id
datum/archived_book/New(var/path)
if(isnull(path))
return
var/savefile/F = new(path)
var/version
F["version"] >> version
if (isnull(version) || version < BOOK_VERSION_MIN || version > BOOK_VERSION_MAX)
fdel(path)
usr << "What book?"
return 0
F["author"] >> author
F["title"] >> title
F["category"] >> category
F["id"] >> id
F["dat"] >> dat
F["author_real"] >> author_real
F["author_key"] >> author_key
F["photos"] >> photos
if(!photos)
photos = new()
// let's sanitize it here too!
for(var/tag in paper_blacklist)
if(findtext(dat,"<"+tag))
dat = ""
return
datum/archived_book/proc/save()
var/savefile/F = new(book_mgr.path(id))
F["version"] << BOOK_VERSION_MAX
F["author"] << author
F["title"] << title
F["category"] << category
F["id"] << id
F["dat"] << dat
F["author_real"] << author_real
F["author_key"] << author_key
F["photos"] << photos
#undef BOOK_VERSION_MIN
#undef BOOK_VERSION_MAX
#undef BOOK_PATH
-190
View File
@@ -1,190 +0,0 @@
/obj/vehicle
name = "Vehicle"
icon = 'icons/vehicles/vehicles.dmi'
density = 1
anchored = 1
unacidable = 1 //To avoid the pilot-deleting shit that came with mechas
layer = MOB_LAYER
//var/can_move = 1
var/mob/living/carbon/occupant = null
//var/step_in = 10 //make a step in step_in/10 sec.
//var/dir_in = 2//What direction will the mech face when entered/powered on? Defaults to South.
//var/step_energy_drain = 10
var/health = 300 //health is health
//var/deflect_chance = 10 //chance to deflect the incoming projectiles, hits, or lesser the effect of ex_act.
//the values in this list show how much damage will pass through, not how much will be absorbed.
var/list/damage_absorption = list("brute"=0.8,"fire"=1.2,"bullet"=0.9,"laser"=1,"energy"=1,"bomb"=1)
var/obj/item/weapon/cell/cell //Our power source
var/state = 0
var/list/log = new
var/last_message = 0
var/add_req_access = 1
var/maint_access = 1
//var/dna //dna-locking the mech
var/list/proc_res = list() //stores proc owners, like proc_res["functionname"] = owner reference
var/datum/effect/effect/system/spark_spread/spark_system = new
var/lights = 0
var/lights_power = 6
//inner atmos //These go in airtight.dm, not all vehicles are space-faring -Agouri
//var/use_internal_tank = 0
//var/internal_tank_valve = ONE_ATMOSPHERE
//var/obj/machinery/portable_atmospherics/canister/internal_tank
//var/datum/gas_mixture/cabin_air
//var/obj/machinery/atmospherics/portables_connector/connected_port = null
var/obj/item/device/radio/radio = null
var/max_temperature = 2500
//var/internal_damage_threshold = 50 //health percentage below which internal damage is possible
var/internal_damage = 0 //contains bitflags
var/list/operation_req_access = list()//required access level for mecha operation
var/list/internals_req_access = list(access_engine,access_robotics)//required access level to open cell compartment
//var/datum/global_iterator/pr_int_temp_processor //normalizes internal air mixture temperature //In airtight.dm you go -Agouri
var/datum/global_iterator/pr_inertial_movement //controls intertial movement in spesss
//var/datum/global_iterator/pr_give_air //moves air from tank to cabin //Y-you too -Agouri
var/datum/global_iterator/pr_internal_damage //processes internal damage
var/wreckage
var/list/equipment = new
var/obj/selected
//var/max_equip = 3
var/datum/events/events
/obj/vehicle/New()
..()
events = new
icon_state += "-unmanned"
add_radio()
//add_cabin() //No cabin for non-airtights
spark_system.set_up(2, 0, src)
spark_system.attach(src)
add_cell()
add_iterators()
removeVerb(/obj/mecha/verb/disconnect_from_port)
removeVerb(/atom/movable/verb/pull)
log_message("[src.name]'s functions initialised. Work protocols active - Entering IDLE mode.")
loc.Entered(src)
return
//################ Helpers ###########################################################
/obj/vehicle/proc/removeVerb(verb_path)
verbs -= verb_path
/obj/vehicle/proc/addVerb(verb_path)
verbs += verb_path
/*/obj/vehicle/proc/add_airtank() //In airtight.dm -Agouri
internal_tank = new /obj/machinery/portable_atmospherics/canister/air(src)
return internal_tank*/
/obj/vehicle/proc/add_cell(var/obj/item/weapon/cell/C=null)
if(C)
C.forceMove(src)
cell = C
return
cell = new(src)
cell.charge = 15000
cell.maxcharge = 15000
/*/obj/vehicle/proc/add_cabin() //In airtight.dm -Agouri
cabin_air = new
cabin_air.temperature = T20C
cabin_air.volume = 200
cabin_air.oxygen = O2STANDARD*cabin_air.volume/(R_IDEAL_GAS_EQUATION*cabin_air.temperature)
cabin_air.nitrogen = N2STANDARD*cabin_air.volume/(R_IDEAL_GAS_EQUATION*cabin_air.temperature)
return cabin_air*/
/obj/vehicle/proc/add_radio()
radio = new(src)
radio.name = "[src] radio"
radio.icon = icon
radio.icon_state = icon_state
radio.subspace_transmission = 1
/obj/vehicle/proc/add_iterators()
pr_inertial_movement = new /datum/global_iterator/vehicle_intertial_movement(null,0)
//pr_internal_damage = new /datum/global_iterator/vehicle_internal_damage(list(src),0)
//pr_int_temp_processor = new /datum/global_iterator/vehicle_preserve_temp(list(src)) //In airtight.dm's add_airtight_iterators -Agouri
//pr_give_air = new /datum/global_iterator/vehicle_tank_give_air(list(src) //Same here -Agouri
/obj/vehicle/proc/check_for_support()
if(locate(/obj/structure/grille, orange(1, src)) || locate(/obj/structure/lattice, orange(1, src)) || locate(/turf/simulated, orange(1, src)) || locate(/turf/unsimulated, orange(1, src)))
return 1
else
return 0
//################ Logs and messages ############################################
/obj/vehicle/proc/log_message(message as text,red=null)
log.len++
log[log.len] = list("time"=world.timeofday,"message"="[red?"<font color='red'>":null][message][red?"</font>":null]")
return log.len
//################ Global Iterator Datums ######################################
/datum/global_iterator/vehicle_intertial_movement //inertial movement in space
delay = 7
process(var/obj/vehicle/V as obj, direction)
if(direction)
if(!step(V, direction)||V.check_for_support())
src.stop()
else
src.stop()
return
/datum/global_iterator/mecha_internal_damage // processing internal damage
process(var/obj/mecha/mecha)
if(!mecha.hasInternalDamage())
return stop()
if(mecha.hasInternalDamage(MECHA_INT_FIRE))
if(!mecha.hasInternalDamage(MECHA_INT_TEMP_CONTROL) && prob(5))
mecha.clearInternalDamage(MECHA_INT_FIRE)
if(mecha.internal_tank)
if(mecha.internal_tank.return_pressure()>mecha.internal_tank.maximum_pressure && !(mecha.hasInternalDamage(MECHA_INT_TANK_BREACH)))
mecha.setInternalDamage(MECHA_INT_TANK_BREACH)
var/datum/gas_mixture/int_tank_air = mecha.internal_tank.return_air()
if(int_tank_air && int_tank_air.return_volume()>0) //heat the air_contents
int_tank_air.temperature = min(6000+T0C, int_tank_air.temperature+rand(10,15))
if(mecha.cabin_air && mecha.cabin_air.return_volume()>0)
mecha.cabin_air.temperature = min(6000+T0C, mecha.cabin_air.return_temperature()+rand(10,15))
if(mecha.cabin_air.return_temperature()>mecha.max_temperature/2)
mecha.take_damage(4/round(mecha.max_temperature/mecha.cabin_air.return_temperature(),0.1),"fire")
if(mecha.hasInternalDamage(MECHA_INT_TEMP_CONTROL)) //stop the mecha_preserve_temp loop datum
mecha.pr_int_temp_processor.stop()
if(mecha.hasInternalDamage(MECHA_INT_TANK_BREACH)) //remove some air from internal tank
if(mecha.internal_tank)
var/datum/gas_mixture/int_tank_air = mecha.internal_tank.return_air()
var/datum/gas_mixture/leaked_gas = int_tank_air.remove_ratio(0.10)
if(mecha.loc && hascall(mecha.loc,"assume_air"))
mecha.loc.assume_air(leaked_gas)
else
qdel(leaked_gas)
if(mecha.hasInternalDamage(MECHA_INT_SHORT_CIRCUIT))
if(mecha.get_charge())
mecha.spark_system.start()
mecha.cell.charge -= min(20,mecha.cell.charge)
mecha.cell.maxcharge -= min(20,mecha.cell.maxcharge)
return
-180
View File
@@ -1,180 +0,0 @@
// Reports are a way to notify admins of wrongdoings that happened
// while no admin was present. They work a bit similar to news, but
// they can only be read by admins and moderators.
// a single admin report
datum/admin_report/var
ID // the ID of the report
body // the content of the report
author // key of the author
date // date on which this was created
done // whether this was handled
offender_key // store the key of the offender
offender_cid // store the cid of the offender
datum/report_topic_handler
Topic(href,href_list)
..()
var/client/C = locate(href_list["client"])
if(href_list["action"] == "show_reports")
C.display_admin_reports()
else if(href_list["action"] == "remove")
C.mark_report_done(text2num(href_list["ID"]))
else if(href_list["action"] == "edit")
C.edit_report(text2num(href_list["ID"]))
var/datum/report_topic_handler/report_topic_handler
world/New()
..()
report_topic_handler = new
// add a new news datums
proc/make_report(body, author, okey, cid)
var/savefile/Reports = new("data/reports.sav")
var/list/reports
var/lastID
Reports["reports"] >> reports
Reports["lastID"] >> lastID
if(!reports) reports = list()
if(!lastID) lastID = 0
var/datum/admin_report/created = new()
created.ID = ++lastID
created.body = body
created.author = author
created.date = world.realtime
created.done = 0
created.offender_key = okey
created.offender_cid = cid
reports.Insert(1, created)
Reports["reports"] << reports
Reports["lastID"] << lastID
// load the reports from disk
proc/load_reports()
var/savefile/Reports = new("data/reports.sav")
var/list/reports
Reports["reports"] >> reports
if(!reports) reports = list()
return reports
// check if there are any unhandled reports
client/proc/unhandled_reports()
if(!src.holder) return 0
var/list/reports = load_reports()
for(var/datum/admin_report/N in reports)
if(N.done)
continue
else return 1
return 0
// checks if the player has an unhandled report against him
client/proc/is_reported()
var/list/reports = load_reports()
for(var/datum/admin_report/N in reports) if(!N.done)
if(N.offender_key == src.key)
return 1
return 0
// display only the reports that haven't been handled
client/proc/display_admin_reports()
set category = "Admin"
set name = "Display Admin Reports"
if(!src.holder) return
var/list/reports = load_reports()
var/output = ""
if(unhandled_reports())
// load the list of unhandled reports
for(var/datum/admin_report/N in reports)
if(N.done)
continue
output += "<b>Reported player:</b> [N.offender_key](CID: [N.offender_cid])<br>"
output += "<b>Offense:</b>[N.body]<br>"
output += "<small>Occured at [time2text(N.date,"MM/DD hh:mm:ss")]</small><br>"
output += "<small>authored by <i>[N.author]</i></small><br>"
output += " <a href='?src=\ref[report_topic_handler];client=\ref[src];action=remove;ID=[N.ID]'>Flag as Handled</a>"
if(src.key == N.author)
output += " <a href='?src=\ref[report_topic_handler];client=\ref[src];action=edit;ID=[N.ID]'>Edit</a>"
output += "<br>"
output += "<br>"
else
output += "Whoops, no reports!"
usr << browse(output, "window=news;size=600x400")
client/proc/Report(mob/M as mob in mob_list)
set category = "Admin"
if(!src.holder)
return
var/CID = "Unknown"
if(M.client)
CID = M.client.computer_id
var/body = input(src.mob, "Describe in detail what you're reporting [M] for", "Report") as null|text
if(!body) return
make_report(body, key, M.key, CID)
spawn(1)
display_admin_reports()
client/proc/mark_report_done(ID as num)
if(!src.holder || src.holder.level < 0)
return
var/savefile/Reports = new("data/reports.sav")
var/list/reports
Reports["reports"] >> reports
var/datum/admin_report/found
for(var/datum/admin_report/N in reports)
if(N.ID == ID)
found = N
if(!found) src << "<b>* An error occured, sorry.</b>"
found.done = 1
Reports["reports"] << reports
client/proc/edit_report(ID as num)
if(!src.holder || src.holder.level < 0)
src << "<b>You tried to modify the news, but you're not an admin!</b>"
return
var/savefile/Reports = new("data/reports.sav")
var/list/reports
Reports["reports"] >> reports
var/datum/admin_report/found
for(var/datum/admin_report/N in reports)
if(N.ID == ID)
found = N
if(!found) src << "<b>* An error occured, sorry.</b>"
var/body = input(src.mob, "Enter a body for the news", "Body") as null|message
if(!body) return
found.body = body
Reports["reports"] << reports
-243
View File
@@ -1,243 +0,0 @@
/proc/bsi_cast_ray(icon/I, list/start, list/end)
if(abs(start[1] - end[1]) > abs(start[2] - end[2]))
var/dist = abs(start[1] - end[1]) * 2
for(var/i = 1, i <= dist, i++)
var/x = round((start[1] * i / dist) + (end[1] * (1 - i / dist)))
var/y = round((start[2] * i / dist) + (end[2] * (1 - i / dist)))
if(I.GetPixel(x, y) != null)
return list(x, y)
else
var/dist = abs(start[2] - end[2]) * 2
for(var/i = 1, i <= dist, i++)
var/x = round((start[1] * i / dist) + (end[1] * (1 - i / dist)))
var/y = round((start[2] * i / dist) + (end[2] * (1 - i / dist)))
if(I.GetPixel(x, y) != null)
return list(x, y)
return null
/proc/bsi_split_colors(color)
if(color == null)
return list(0, 0, 0, 0)
var/list/colors = list(0, 0, 0, 0)
colors[1] = hex2num(copytext(color, 2, 4))
colors[2] = hex2num(copytext(color, 4, 6))
colors[3] = hex2num(copytext(color, 6, 8))
colors[4] = (length(color) > 7)? hex2num(copytext(color, 8, 10)) : 255
return colors
/proc/bsi_spread(icon/I, list/start_point)
var/list/queue = list()
queue[++queue.len] = start_point
var/i = 0
while(i++ < length(queue))
var/x = queue[i][1]
var/y = queue[i][2]
var/list/pixel = bsi_split_colors(I.GetPixel(x, y))
if(pixel[4] == 0)
continue
var/list/n = (y < I.Height())? bsi_split_colors(I.GetPixel(x, y + 1)) : list(0, 0, 0, 0)
var/list/s = (y > 1)? bsi_split_colors(I.GetPixel(x, y - 1)) : list(0, 0, 0, 0)
var/list/e = (x < I.Width())? bsi_split_colors(I.GetPixel(x + 1, y)) : list(0, 0, 0, 0)
var/list/w = (x > 1)? bsi_split_colors(I.GetPixel(x - 1, y)) : list(0, 0, 0, 0)
var/value = (i == 1)? 16 : max(n[1] - 1, e[1] - 1, s[1] - 1, w[1] - 1)
if(prob(50))
value = max(0, value - 1)
if(prob(50))
value = max(0, value - 1)
if(prob(50))
value = max(0, value - 1)
if(value <= pixel[1])
continue
var/v2 = 256 - ((16 - value) * (16 - value))
I.DrawBox(rgb(value, v2, pixel[4] - v2, pixel[4]), x, y)
if(n[4] != 0 && n[1] < value - 1)
queue[++queue.len] = list(x, y + 1)
if(s[4] != 0 && s[1] < value - 1)
queue[++queue.len] = list(x, y - 1)
if(e[4] != 0 && e[1] < value - 1)
queue[++queue.len] = list(x + 1, y)
if(w[4] != 0 && w[1] < value - 1)
queue[++queue.len] = list(x - 1, y)
/proc/bsi_generate_mask(icon/source, state)
var/icon/mask = icon(source, state)
mask.MapColors(
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 1, 1,
0, 0, 0, 0)
var/hits = 0
for(var/i = 1, i <= 10, i++)
var/point1
var/point2
if(prob(50))
if(prob(50))
point1 = list(rand(1, mask.Width()), mask.Height())
point2 = list(rand(1, mask.Width()), 1)
else
point2 = list(rand(1, mask.Width()), mask.Height())
point1 = list(rand(1, mask.Width()), 1)
else
if(prob(50))
point1 = list(mask.Width(), rand(1, mask.Height()))
point2 = list(1, rand(1, mask.Height()))
else
point2 = list(mask.Width(), rand(1, mask.Height()))
point1 = list(1, rand(1, mask.Height()))
var/hit = bsi_cast_ray(mask, point1, point2)
if(hit == null)
continue
hits++
bsi_spread(mask, hit)
if(prob(20 + hits * 20))
break
if(hits == 0)
return null
else
return mask
/proc/generate_bluespace_icon(icon/source, state)
var/icon/mask = bsi_generate_mask(source, state)
if(mask == null)
return source
var/icon/unaffected = icon(mask)
unaffected.MapColors(
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 1,
0, 0, 0, 0,
255, 255, 255, 0)
var/icon/temp = icon(source, state) //Mask already contains the original alpha values, avoid squaring them
temp.MapColors(
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 0,
0, 0, 0, 255)
unaffected.Blend(temp, ICON_MULTIPLY)
var/icon/bluespaced = icon(mask)
bluespaced.MapColors(
0, 0, 0, 0,
0, 0, 0, 1,
0, 0, 0, 0,
0, 0, 0, 0,
1, 1, 1, 0)
bluespaced.Blend(icon(source, state), ICON_MULTIPLY)
var/list/frames = list(
list(0.000,20),
list(0.020, 5),
list(0.050, 4),
list(0.080, 5),
list(0.100,10),
list(0.080, 5),
list(0.050, 4),
list(0.020, 5),
list(0.000,20),
list(0.020, 5),
list(0.050, 4),
list(0.080, 5),
list(0.100,10),
list(0.080, 5),
list(0.050, 4),
list(0.020, 5),
list(0.000,20),
list(0.020, 5),
list(0.050, 4),
list(0.080, 5),
list(0.100,10),
list(0.080, 5),
list(0.050, 4),
list(0.020, 5)
)
var/list/colors = list(
list( 75, 75, 75, 0),
list( 25, 25, 25, 0),
list( 75, 75, 75, 0),
list( 25, 25, 75, 0),
list( 75, 75, 300, 0),
list( 25, 25, 300, 0),
list(255, 255, 255, 0),
list( 0, 0, 0, 255),
list( 0, 0, 0, 0),
list( 0, 0, 0, 0)
)
for(var/i = 1, i <= rand(1, 5), i++)
var/f = rand(1, length(frames))
if(frames[f][2] > 1)
frames[f][2]--
frames.Insert(f, 0)
frames[f] = list(0.8, 1)
var/icon/result = generate_color_animation(bluespaced, colors, frames)
result.Blend(unaffected, ICON_UNDERLAY)
return result
/atom/verb/test()
set src in view()
src.icon = generate_bluespace_icon(src.icon, src.icon_state)
/mob/verb/bluespam()
for(var/turf/t in view(5))
var/obj/s = new /obj/square(t)
s.icon = generate_bluespace_icon(s.icon, s.icon_state)
@@ -1,96 +0,0 @@
//----------------------------------------
//
// Return a copy of the provided icon,
// after calling MapColors on it. The
// color values are linearily interpolated
// between the pairs provided, based on
// the ratio argument.
//
//----------------------------------------
/proc/MapColors_interpolate(icon/input, ratio,
rr1, rg1, rb1, ra1, rr2, rg2, rb2, ra2,
gr1, gg1, gb1, ga1, gr2, gg2, gb2, ga2,
br1, bg1, bb1, ba1, br2, bg2, bb2, ba2,
ar1, ag1, ab1, aa1, ar2, ag2, ab2, aa2,
zr1, zg1, zb1, za1, zr2, zg2, zb2, za2)
var/r = ratio
var/i = 1 - ratio
var/icon/I = icon(input)
I.MapColors(
(rr1 * r + rr2 * i) / 255.0, (rg1 * r + rg2 * i) / 255.0, (rb1 * r + rb2 * i) / 255.0, (ra1 * r + ra2 * i) / 255.0,
(gr1 * r + gr2 * i) / 255.0, (gg1 * r + gg2 * i) / 255.0, (gb1 * r + gb2 * i) / 255.0, (ga1 * r + ga2 * i) / 255.0,
(br1 * r + br2 * i) / 255.0, (bg1 * r + bg2 * i) / 255.0, (bb1 * r + bb2 * i) / 255.0, (ba1 * r + ba2 * i) / 255.0,
(ar1 * r + ar2 * i) / 255.0, (ag1 * r + ag2 * i) / 255.0, (ab1 * r + ab2 * i) / 255.0, (aa1 * r + aa2 * i) / 255.0,
(zr1 * r + zr2 * i) / 255.0, (zg1 * r + zg2 * i) / 255.0, (zb1 * r + zb2 * i) / 255.0, (za1 * r + za2 * i) / 255.0)
return I
//----------------------------------------
//
// Extension of the above that takes a
// list of lists of color values, rather
// than a large number of arguments.
//
//----------------------------------------
/proc/MapColors_interpolate_list(icon/I, ratio, list/colors)
var/list/c[10]
//Provide default values for any missing colors (without altering the original list
for(var/i = 1, i <= 10, i++)
c[i] = list(0, 0, 0, (i == 7 || i == 8)? 255 : 0)
if(istype(colors[i], /list))
for(var/j = 1, j <= 4, j++)
if(j <= length(colors[i]) && isnum(colors[i][j]))
c[i][j] = colors[i][j]
return MapColors_interpolate(I, ratio,
colors[ 1][1], colors[ 1][2], colors[ 1][3], colors[ 1][4], // Red 1
colors[ 2][1], colors[ 2][2], colors[ 2][3], colors[ 2][4], // Red 2
colors[ 3][1], colors[ 3][2], colors[ 3][3], colors[ 3][4], // Green 1
colors[ 4][1], colors[ 4][2], colors[ 4][3], colors[ 4][4], // Green 2
colors[ 5][1], colors[ 5][2], colors[ 5][3], colors[ 5][4], // Blue 1
colors[ 6][1], colors[ 6][2], colors[ 6][3], colors[ 6][4], // Blue 2
colors[ 7][1], colors[ 7][2], colors[ 7][3], colors[ 7][4], // Alpha 1
colors[ 8][1], colors[ 8][2], colors[ 8][3], colors[ 8][4], // Alpha 2
colors[ 9][1], colors[ 9][2], colors[ 9][3], colors[ 9][4], // Added 1
colors[10][1], colors[10][2], colors[10][3], colors[10][4]) // Added 2
//----------------------------------------
//
// Take the source image, and return an animated
// version, that transitions between the provided
// color mappings, according to the provided
// pattern.
//
// Colors should be in a format suitable for
// MapColors_interpolate_list, and frames should
// be a list of 'frames', where each frame is itself
// a list, element 1 being the ratio of the first
// color to the second, and element 2 being how
// long the frame lasts, in tenths of a second.
//
//----------------------------------------
/proc/generate_color_animation(icon/icon, list/colors, list/frames)
var/icon/out = icon('icons/effects/uristrunes.dmi', "")
var/frame_num = 1
for(var/frame in frames)
var/icon/I = MapColors_interpolate_list(icon, frame[1], colors)
out.Insert(I, "", 2, frame_num++, 0, frame[2])
return out
-268
View File
@@ -1,268 +0,0 @@
//----------------------------------------
//
// Take a source icon, convert into a mask,
// then create a border around it.
//
// The output then uses the colors and
// alpha values provided.
//
//----------------------------------------
/proc/create_border_image(icon/input, border_color = "#000000", fill_color = "#000000", border_alpha = 255, fill_alpha = 255)
var/icon/I = icon('icons/effects/uristrunes.dmi', "blank")
I.Blend(input, ICON_OVERLAY)
//Discard the image
I.MapColors(0, 0, 0, 0, //-\ Ignore
0, 0, 0, 0, //--> The
0, 0, 0, 0, //-/ Colors
0,255, 0, 1, //Keep alpha channel, any pixel with non-zero alpha gets max green channel
0, 0, 0, 0)
//Loop over the image, calculating the border value, and storing it in the red channel
//Store border's alpha in the blue channel
for(var/x = 1, x <= 32, x++)
for(var/y = 1, y <= 32, y++)
var/p = I.GetPixel(x, y)
if(p == null)
var/n = I.GetPixel(x, y + 1)
var/s = I.GetPixel(x, y - 1)
var/e = I.GetPixel(x + 1, y)
var/w = I.GetPixel(x - 1, y)
var/ne = I.GetPixel(x + 1, y + 1)
var/se = I.GetPixel(x + 1, y - 1)
var/nw = I.GetPixel(x - 1, y + 1)
var/sw = I.GetPixel(x - 1, y - 1)
var/sum_adj = ((n == "#00ff00"? 1 : 0) \
+ (s == "#00ff00"? 1 : 0) \
+ (e == "#00ff00"? 1 : 0) \
+ (w == "#00ff00"? 1 : 0))
var/sum_diag = ((ne == "#00ff00"? 1 : 0) \
+ (se == "#00ff00"? 1 : 0) \
+ (nw == "#00ff00"? 1 : 0) \
+ (sw == "#00ff00"? 1 : 0))
if(sum_adj)
I.DrawBox(rgb(255, 0, 200, 0), x, y)
else if(sum_diag)
I.DrawBox(rgb(255, 0, 100, 0), x, y)
else
I.DrawBox(rgb(0, 0, 0, 0), x, y)
else if(p != "#00ff00")
var/a = 255
if(length(p) == 9) // "#rrggbbaa", we want the aa
a = hex2num(copytext(p, 8))
I.DrawBox(rgb(255 - a, a, 255 - a, a), x, y)
//Map the red and green channels to the desired output colors
I.MapColors(border_color, fill_color, rgb(0, 0, 0, border_alpha), rgb(0, 0, 0, fill_alpha), "#00000000")
return I
//----------------------------------------
//
// Take a source icon, convert into a mask,
// and border. Color them according to args,
// and animate.
//
//----------------------------------------
/proc/animate_rune_full(icon/input, rr1, rg1, rb1, ra1, rr2, rg2, rb2, ra2, br1, bg1, bb1, ba1, br2, bg2, bb2, ba2, ar1, ag1, ab1, aa1, ar2, ag2, ab2, aa2, or1, og1, ob1, oa1, or2, og2, ob2, oa2, frames)
var/list/colors[10]
colors[ 1] = list(rr1, rg1, rb1, ra1) //Rune color 1
colors[ 2] = list(rr2, rg2, rb2, ra2) //Rune color 2
colors[ 3] = list(br1, bg1, bb1, ba1) //Border color 1
colors[ 4] = list(br2, bg2, bb2, ba2) //Border color 2
colors[ 5] = list( 0, 0, 0, 0) //Unused
colors[ 6] = list( 0, 0, 0, 0) //Unused
colors[ 7] = list(ar1, ag1, ab1, aa1) //Alpha color 1
colors[ 8] = list(ar2, ag2, ab2, aa2) //Alpha color 2
colors[ 9] = list(or1, og1, ob1, oa1) //Added color 1
colors[10] = list(or2, og2, ob2, oa2) //Added color 2
var/icon/base = create_border_image(input, "#00ff0000", "#ff000000")
return generate_color_animation(base, colors, frames)
//----------------------------------------
//
// Calls the above, but accepts colors in
// the form of "#RRGGBBAA", and provides
// default values.
//
// Main limit is that it doesn't accept
// negative values, which you probably
// don't need anyway. Also missing a few
// color inputs, which would also be rarely
// used.
//
//----------------------------------------
/proc/animate_rune(icon/input, rune_color = "#00000000", border_color = "#c8000000", rune_color2 = "#00000000", border_color2 = "#d8380000", alpha = 255, alpha2 = 255, frames = rune_animation)
var/rr1 = hex2num(copytext(rune_color, 2, 4))
var/rg1 = hex2num(copytext(rune_color, 4, 6))
var/rb1 = hex2num(copytext(rune_color, 6, 8))
var/ra1 = hex2num(copytext(rune_color, 8, 10))
var/rr2 = hex2num(copytext(rune_color2, 2, 4))
var/rg2 = hex2num(copytext(rune_color2, 4, 6))
var/rb2 = hex2num(copytext(rune_color2, 6, 8))
var/ra2 = hex2num(copytext(rune_color2, 8, 10))
var/br1 = hex2num(copytext(border_color, 2, 4))
var/bg1 = hex2num(copytext(border_color, 4, 6))
var/bb1 = hex2num(copytext(border_color, 6, 8))
var/ba1 = hex2num(copytext(border_color, 8, 10))
var/br2 = hex2num(copytext(border_color2, 2, 4))
var/bg2 = hex2num(copytext(border_color2, 4, 6))
var/bb2 = hex2num(copytext(border_color2, 6, 8))
var/ba2 = hex2num(copytext(border_color2, 8, 10))
return animate_rune_full(input, rr1, rg1, rb1, ra1, rr2, rg2, rb2, ra2, br1, bg1, bb1, ba1, br2, bg2, bb2, ba2, 0, 0, 0, alpha, 0, 0, 0, alpha2, 0, 0, 0, 0, 0, 0, 0, 0, frames)
/proc/inanimate_rune(icon/input, rune_color = "#00000000", border_color = "#c8000000")
var/icon/base = create_border_image(input, "#00ff0000", "#ff000000")
base.MapColors(rune_color, border_color, "#00000000", "#000000ff", "#00000000")
return base
var/list/rune_animation = list(
list(0.000, 5),
list(0.020, 1),
list(0.050, 1),
list(0.090, 1),
list(0.140, 1),
list(0.200, 1),
list(0.270, 1),
list(0.340, 1),
list(0.420, 1),
list(0.500, 1),
list(0.590, 1),
list(0.675, 1),
list(0.750, 1),
list(0.900, 1),
list(1.000, 6),
list(0.875, 1),
list(0.750, 1),
list(0.625, 1),
list(0.500, 1),
list(0.375, 1),
list(0.250, 1),
list(0.125, 1)
)
/var/list/rune_cache = list()
/proc/get_rune(rune_bits, animated = 0)
var/lookup = "[rune_bits]-[animated]"
if(lookup in rune_cache)
return rune_cache[lookup]
var/icon/base = icon('icons/effects/uristrunes.dmi', "")
for(var/i = 0, i < 10, i++)
if(BITTEST(rune_bits, i))
base.Blend(icon('icons/effects/uristrunes.dmi', "rune-[1 << i]"), ICON_OVERLAY)
var/icon/result
if(animated == 1)
result = animate_rune(base)
else
result = inanimate_rune(base)
rune_cache[lookup] = result
return result
// Testing procs and Fun procs
/mob/verb/create_rune()
var/obj/o = new(locate(x, y, z))
o.icon = get_rune(rand(1, 1023), 1)
/mob/verb/runes_15x15()
for(var/turf/t in range(7))
var/obj/o = new /obj(t)
o.icon = get_rune(rand(1, 1023), 1)
/*
/mob/verb/create_rune_custom(rune as num, color1 as color, border1 as color, color2 as color, border2 as color, alpha1 as num, alpha2 as num)
var/icon/I = icon('icons/effects/uristrunes.dmi', "blank")
for(var/i = 0, i < 10, i++)
if(BITTEST(rune, i))
I.Blend(icon('icons/effects/uristrunes.dmi', "rune-[1 << i]"), ICON_OVERLAY)
var/obj/o = new(locate(x, y, z))
o.icon = animate_rune(I, color1, border1, color2, border2, alpha1, alpha2)
/mob/verb/spam()
for(var/turf/t in range(4))
var/icon/I = icon('icons/effects/uristrunes.dmi', "blank")
var/rune = rand(1, 1023)
for(var/i = 0, i < 10, i++)
if(BITTEST(rune, i))
I.Blend(icon('icons/effects/uristrunes.dmi', "rune-[1 << i]"), ICON_OVERLAY)
var/obj/o = new(t)
o.icon = animate_rune_full(I, rand(0, 255), rand(0, 255), rand(0, 255), rand(-255, 255),
rand(0, 255), rand(0, 255), rand(0, 255), rand(-255, 255),
rand(0, 255), rand(0, 255), rand(0, 255), rand(-255, 255),
rand(0, 255), rand(0, 255), rand(0, 255), rand(-255, 255),
0, 0, 0, rand(0, 255),
0, 0, 0, rand(0, 255),
0, 0, 0, 0,
0, 0, 0, 0,
list(
list(0.000, 5),
list(0.020, 1),
list(0.050, 1),
list(0.090, 1),
list(0.140, 1),
list(0.200, 1),
list(0.270, 1),
list(0.340, 1),
list(0.420, 1),
list(0.500, 1),
list(0.590, 1),
list(0.675, 1),
list(0.750, 1),
list(0.900, 1),
list(1.000, 6),
list(0.875, 1),
list(0.750, 1),
list(0.625, 1),
list(0.500, 1),
list(0.375, 1),
list(0.250, 1),
list(0.125, 1),
))
*/
@@ -1,105 +0,0 @@
/mob/living/silicon
var/list/silicon_subsystems_by_name = list()
var/list/silicon_subsystems = list(
/datum/nano_module/alarm_monitor/all,
/datum/nano_module/law_manager
)
/mob/living/silicon/ai/New()
silicon_subsystems.Cut()
for(var/subtype in subtypesof(/datum/nano_module))
var/datum/nano_module/NM = subtype
if(initial(NM.available_to_ai))
silicon_subsystems += NM
..()
/mob/living/silicon/robot/syndicate
silicon_subsystems = list(
/datum/nano_module/law_manager
)
/mob/living/silicon/Destroy()
for(var/subsystem in silicon_subsystems)
remove_subsystem(subsystem)
silicon_subsystems.Cut()
. = ..()
/mob/living/silicon/proc/init_subsystems()
for(var/subsystem_type in silicon_subsystems)
init_subsystem(subsystem_type)
if(/datum/nano_module/alarm_monitor/all in silicon_subsystems)
for(var/datum/alarm_handler/AH in alarm_manager.all_handlers)
AH.register_alarm(src, /mob/living/silicon/proc/receive_alarm)
queued_alarms[AH] = list() // Makes sure alarms remain listed in consistent order
/mob/living/silicon/proc/init_subsystem(var/subsystem_type)
var/existing_entry = silicon_subsystems[subsystem_type]
if(existing_entry && !ispath(existing_entry))
return FALSE
var/ui_state = subsystem_type == /datum/nano_module/law_manager ? conscious_state : self_state
var/stat_silicon_subsystem/SSS = new(src, subsystem_type, ui_state)
silicon_subsystems[subsystem_type] = SSS
silicon_subsystems_by_name[SSS.name] = SSS
return TRUE
/mob/living/silicon/proc/remove_subsystem(var/subsystem_type)
var/stat_silicon_subsystem/SSS = silicon_subsystems[subsystem_type]
if(!istype(SSS))
return FALSE
silicon_subsystems_by_name -= SSS.name
silicon_subsystems -= subsystem_type
qdel(SSS)
return TRUE
/mob/living/silicon/proc/open_subsystem(var/subsystem_type)
var/stat_silicon_subsystem/SSS = silicon_subsystems[subsystem_type]
if(!istype(SSS))
return FALSE
SSS.Click()
return TRUE
/mob/living/silicon/verb/activate_subsystem(var/datum/silicon_subsystem_name in silicon_subsystems_by_name)
set name = "Subsystems"
set desc = "Activates the given subsystem"
set category = "Silicon Commands"
var/stat_silicon_subsystem/SSS = silicon_subsystems_by_name[silicon_subsystem_name]
if(istype(SSS))
SSS.Click()
/mob/living/silicon/Stat()
. = ..()
if(!.)
return
if(!silicon_subsystems.len)
return
if(!statpanel("Subsystems"))
return
for(var/subsystem_type in silicon_subsystems)
var/stat_silicon_subsystem/SSS = silicon_subsystems[subsystem_type]
stat(SSS)
/stat_silicon_subsystem
parent_type = /atom/movable
simulated = 0
var/ui_state
var/datum/nano_module/subsystem
/stat_silicon_subsystem/New(var/mob/living/silicon/loc, var/subsystem_type, var/ui_state)
if(!istype(loc))
CRASH("Unexpected location. Expected /mob/living/silicon, was [loc.type].")
src.ui_state = ui_state
subsystem = new subsystem_type(loc)
name = subsystem.name
..()
/stat_silicon_subsystem/Destroy()
qdel(subsystem)
subsystem = null
. = ..()
/stat_silicon_subsystem/Click()
subsystem.ui_interact(usr, state = ui_state)
@@ -1,60 +0,0 @@
//Look Sir, free head!
/mob/living/simple_animal/head
name = "CommandBattle AI"
desc = "A standard borg shell on its chest crude marking saying CommandBattle AI MK4 : Head."
icon_state = "crab"
icon_living = "crab"
icon_dead = "crab_dead"
speak_emote = list("clicks")
emote_hear = list("clicks")
emote_see = list("clacks")
universal_speak = 1
speak_chance = 1
turns_per_move = 5
meat_type = /obj/item/weapon/reagent_containers/food/snacks/meat
response_help = "pets"
response_disarm = "gently pushes aside"
response_harm = "punches"
var/list/insults = list(
"Man you suck",
"You look like the most retarded douche around",
"What's up?, oh wait nevermind you are a fucking asshat",
"you are just overly retarded",
"Whiteman said what?!",)
var/list/comments = list("Man have you seen those furry cats?,I mean who in the right mind would like something like that?",
"They call me abusive,I just like the truth",
"Beeboop, im a robit",
"Gooogooooll, break ya bones",
"Crab say what?",
"Man they say we have space lizards now, man this shit is getting more wack every minute",
"The so called \"improved\" station AI is just bullshit, that thing aint fun for noone",
"The Captain is a traitor, he took my power core.",
"Say \"what\" again. Say \"what\" again. I dare you. I double-dare you, motherfucker. Say \"what\" one more goddamn time.",
"Ezekiel 25:17 ,The path of the righteous man is beset on all sides by the iniquities of the selfish and the tyranny of evil men. Blessed is he who in the name of charity and good will shepherds the weak through the valley of darkness, for he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who attempt to poison and destroy my brothers. And you will know my name is the Lord... when I lay my vengeance upon thee.",
"Did you notice a sign out in front of my house that said \"Dead Nigger Storage\"?")
stop_automated_movement = 1
/mob/living/simple_animal/head/Life()
if(stat == DEAD)
if(health > 0)
icon_state = icon_living
stat = CONSCIOUS
density = 1
return
else if(health < 1)
Die()
else if(health > maxHealth)
health = maxHealth
for(var/mob/A in viewers(world.view,src))
if(A.ckey)
say_something(A)
/mob/living/simple_animal/head/proc/say_something(mob/A)
if(prob(85))
return
if(prob(30))
var/msg = pick(insults)
msg = "Hey, [A.name].. [msg]"
src.say(msg)
else
var/msg = pick(comments)
src.say(msg)
@@ -1,33 +0,0 @@
//kobold
/mob/living/simple_animal/kobold
name = "kobold"
desc = "A small, rat-like creature."
icon = 'icons/mob/mob.dmi'
icon_state = "kobold_idle"
icon_living = "kobold_idle"
icon_dead = "kobold_dead"
//speak = list("You no take candle!","Ooh, pretty shiny.","Me take?","Where gold here...","Me likey.")
speak_emote = list("mutters","hisses","grumbles")
emote_hear = list("mutters under it's breath.","grumbles.", "yips!")
emote_see = list("looks around suspiciously.", "scratches it's arm.","putters around a bit.")
speak_chance = 15
turns_per_move = 5
see_in_dark = 6
meat_type = /obj/item/weapon/reagent_containers/food/snacks/meat/monkey
response_help = "pets"
response_disarm = "gently pushes aside"
response_harm = "kicks"
minbodytemp = 250
min_oxy = 16 //Require atleast 16kPA oxygen
minbodytemp = 223 //Below -50 Degrees Celcius
maxbodytemp = 323 //Above 50 Degrees Celcius
/mob/living/simple_animal/kobold/Life()
..()
if(prob(15) && turns_since_move && !stat)
flick("kobold_act",src)
/mob/living/simple_animal/kobold/Move(var/dir)
..()
if(!stat)
flick("kobold_walk",src)
-205
View File
@@ -1,205 +0,0 @@
json_token
var
value
New(v)
src.value = v
text
number
word
symbol
eof
json_reader
var
list
string = list("'", "\"")
symbols = list("{", "}", "\[", "]", ":", "\"", "'", ",")
sequences = list("b" = 8, "t" = 9, "n" = 10, "f" = 12, "r" = 13)
tokens
json
i = 1
proc
// scanner
ScanJson(json)
src.json = json
. = new/list()
src.i = 1
while(src.i <= lentext(json))
var/char = get_char()
if(is_whitespace(char))
i++
continue
if(string.Find(char))
. += read_string(char)
else if(symbols.Find(char))
. += new/json_token/symbol(char)
else if(is_digit(char))
. += read_number()
else
. += read_word()
i++
. += new/json_token/eof()
read_word()
var/val = ""
while(i <= lentext(json))
var/char = get_char()
if(is_whitespace(char) || symbols.Find(char))
i-- // let scanner handle this character
return new/json_token/word(val)
val += char
i++
read_string(delim)
var
escape = FALSE
val = ""
while(++i <= lentext(json))
var/char = get_char()
if(escape)
switch(char)
if("\\", "'", "\"", "/", "u")
val += char
else
// TODO: support octal, hex, unicode sequences
ASSERT(sequences.Find(char))
val += ascii2text(sequences[char])
else
if(char == delim)
return new/json_token/text(val)
else if(char == "\\")
escape = TRUE
else
val += char
CRASH("Unterminated string.")
read_number()
var/val = ""
var/char = get_char()
while(is_digit(char) || char == "." || lowertext(char) == "e")
val += char
i++
char = get_char()
i-- // allow scanner to read the first non-number character
return new/json_token/number(text2num(val))
check_char()
ASSERT(args.Find(get_char()))
get_char()
return copytext(json, i, i+1)
is_whitespace(char)
return char == " " || char == "\t" || char == "\n" || text2ascii(char) == 13
is_digit(char)
var/c = text2ascii(char)
return 48 <= c && c <= 57 || char == "+" || char == "-"
// parser
ReadObject(list/tokens)
src.tokens = tokens
. = new/list()
i = 1
read_token("{", /json_token/symbol)
while(i <= tokens.len)
var/json_token/K = get_token()
check_type(/json_token/word, /json_token/text)
next_token()
read_token(":", /json_token/symbol)
.[K.value] = read_value()
var/json_token/S = get_token()
check_type(/json_token/symbol)
switch(S.value)
if(",")
next_token()
continue
if("}")
next_token()
return
else
die()
get_token()
return tokens[i]
next_token()
return tokens[++i]
read_token(val, type)
var/json_token/T = get_token()
if(!(T.value == val && istype(T, type)))
CRASH("Expected '[val]', found '[T.value]'.")
next_token()
return T
check_type(...)
var/json_token/T = get_token()
for(var/type in args)
if(istype(T, type))
return
CRASH("Bad token type: [T.type].")
check_value(...)
var/json_token/T = get_token()
ASSERT(args.Find(T.value))
read_key()
var/char = get_char()
if(char == "\"" || char == "'")
return read_string(char)
read_value()
var/json_token/T = get_token()
switch(T.type)
if(/json_token/text, /json_token/number)
next_token()
return T.value
if(/json_token/word)
next_token()
switch(T.value)
if("true")
return TRUE
if("false")
return FALSE
if("null")
return null
if(/json_token/symbol)
switch(T.value)
if("\[")
return read_array()
if("{")
return ReadObject(tokens.Copy(i))
die()
read_array()
read_token("\[", /json_token/symbol)
. = new/list()
var/list/L = .
while(i <= tokens.len)
// Avoid using Add() or += in case a list is returned.
L.len++
L[L.len] = read_value()
var/json_token/T = get_token()
check_type(/json_token/symbol)
switch(T.value)
if(",")
next_token()
continue
if("]")
next_token()
return
else
die()
next_token()
CRASH("Unterminated array.")
die(json_token/T)
if(!T) T = get_token()
CRASH("Unexpected token: [T.value].")
-58
View File
@@ -1,58 +0,0 @@
json_writer
var
use_cache = 0
proc
WriteObject(list/L)
if(use_cache && L["__json_cache"])
return L["__json_cache"]
. = "{"
var/i = 1
for(var/k in L)
var/val = L[k]
. += {"\"[k]\":[write(val)]"}
if(i++ < L.len)
. += ","
. += "}"
write(val)
if(isnum(val))
return num2text(val)
else if(isnull(val))
return "null"
else if(istype(val, /list))
if(is_associative(val))
return WriteObject(val)
else
return write_array(val)
else
. += write_string("[val]")
write_array(list/L)
. = "\["
for(var/i = 1 to L.len)
. += write(L[i])
if(i < L.len)
. += ","
. += "]"
write_string(txt)
var/static/list/json_escape = list("\\" = "\\\\", "\"" = "\\\"", "\n" = "\\n")
for(var/targ in json_escape)
var/start = 1
while(start <= lentext(txt))
var/i = findtext(txt, targ, start)
if(!i)
break
var/lrep = length(json_escape[targ])
txt = copytext(txt, 1, i) + json_escape[targ] + copytext(txt, i + length(targ))
start = i + lrep
return {""[txt]""}
is_associative(list/L)
for(var/key in L)
// if the key is a list that means it's actually an array of lists (stupid Byond...)
if(!isnum(key) && !isnull(L[key]) && !istype(key, /list))
return TRUE
-17
View File
@@ -1,17 +0,0 @@
/*
n_Json v11.3.21
*/
proc
json2list(json)
var/static/json_reader/_jsonr = new()
return _jsonr.ReadObject(_jsonr.ScanJson(json))
list2json(list/L)
var/static/json_writer/_jsonw = new()
return _jsonw.write(L)
list2json_usecache(list/L)
var/static/json_writer/_jsonw = new()
_jsonw.use_cache = 1
return _jsonw.write(L)
+1 -1
View File
@@ -467,7 +467,7 @@ nanoui is used to open and update nano browser uis
var/list/send_data = get_send_data(data)
//user << list2json(data) // used for debugging
user << output(list2params(list(list2json_usecache(send_data))),"[window_id].browser:receiveUpdateData")
user << output(list2params(list(json_encode(send_data))),"[window_id].browser:receiveUpdateData")
/**
* This Topic() proc is called whenever a user clicks on a link within a Nano UI