initial commit - cross reference with 5th port - obviously has compile errors
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
/mob/new_player/Login()
|
||||
if(!mind)
|
||||
mind = new /datum/mind(key)
|
||||
mind.active = 1
|
||||
mind.current = src
|
||||
|
||||
..()
|
||||
|
||||
if(join_motd)
|
||||
src << "<div class=\"motd\">[join_motd]</div>"
|
||||
|
||||
if(admin_notice)
|
||||
src << "<span class='notice'><b>Admin Notice:</b>\n \t [admin_notice]</span>"
|
||||
|
||||
if(config.soft_popcap && living_player_count() >= config.soft_popcap)
|
||||
src << "<span class='notice'><b>Server Notice:</b>\n \t [config.soft_popcap_message]</span>"
|
||||
|
||||
sight |= SEE_TURFS
|
||||
|
||||
/*
|
||||
var/list/watch_locations = list()
|
||||
for(var/obj/effect/landmark/landmark in landmarks_list)
|
||||
if(landmark.tag == "landmark*new_player")
|
||||
watch_locations += landmark.loc
|
||||
|
||||
if(watch_locations.len>0)
|
||||
loc = pick(watch_locations)
|
||||
*/
|
||||
new_player_panel()
|
||||
|
||||
spawn(40)
|
||||
if(client)
|
||||
client.playtitlemusic()
|
||||
@@ -0,0 +1,7 @@
|
||||
/mob/new_player/Logout()
|
||||
ready = 0
|
||||
..()
|
||||
if(!spawning)//Here so that if they are spawning and log out, the other procs can play out and they will have a mob to come back to.
|
||||
key = null//We null their key before deleting the mob, so they are properly kicked out.
|
||||
qdel(src)
|
||||
return
|
||||
@@ -0,0 +1,444 @@
|
||||
//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:33
|
||||
|
||||
/mob/new_player
|
||||
var/ready = 0
|
||||
var/spawning = 0//Referenced when you want to delete the new_player later on in the code.
|
||||
|
||||
flags = NONE
|
||||
|
||||
invisibility = INVISIBILITY_ABSTRACT
|
||||
|
||||
density = 0
|
||||
stat = DEAD
|
||||
canmove = 0
|
||||
|
||||
anchored = 1 // don't get pushed around
|
||||
|
||||
/mob/new_player/New()
|
||||
tag = "mob_[next_mob_id++]"
|
||||
mob_list += src
|
||||
|
||||
if(length(newplayer_start))
|
||||
loc = pick(newplayer_start)
|
||||
else
|
||||
loc = locate(1,1,1)
|
||||
|
||||
/mob/new_player/proc/new_player_panel()
|
||||
|
||||
var/output = "<center><p><a href='byond://?src=\ref[src];show_preferences=1'>Setup Character</A></p>"
|
||||
|
||||
if(!ticker || ticker.current_state <= GAME_STATE_PREGAME)
|
||||
if(ready)
|
||||
output += "<p>\[ <b>Ready</b> | <a href='byond://?src=\ref[src];ready=0'>Not Ready</a> \]</p>"
|
||||
else
|
||||
output += "<p>\[ <a href='byond://?src=\ref[src];ready=1'>Ready</a> | <b>Not Ready</b> \]</p>"
|
||||
|
||||
else
|
||||
output += "<p><a href='byond://?src=\ref[src];manifest=1'>View the Crew Manifest</A></p>"
|
||||
output += "<p><a href='byond://?src=\ref[src];late_join=1'>Join Game!</A></p>"
|
||||
|
||||
output += "<p><a href='byond://?src=\ref[src];observe=1'>Observe</A></p>"
|
||||
|
||||
if(!IsGuestKey(src.key))
|
||||
establish_db_connection()
|
||||
|
||||
if(dbcon.IsConnected())
|
||||
var/isadmin = 0
|
||||
if(src.client && src.client.holder)
|
||||
isadmin = 1
|
||||
var/DBQuery/query = dbcon.NewQuery("SELECT id FROM [format_table_name("poll_question")] WHERE [(isadmin ? "" : "adminonly = false AND")] Now() BETWEEN starttime AND endtime AND id NOT IN (SELECT pollid FROM [format_table_name("poll_vote")] WHERE ckey = \"[ckey]\") AND id NOT IN (SELECT pollid FROM [format_table_name("poll_textreply")] WHERE ckey = \"[ckey]\")")
|
||||
query.Execute()
|
||||
var/newpoll = 0
|
||||
while(query.NextRow())
|
||||
newpoll = 1
|
||||
break
|
||||
|
||||
if(newpoll)
|
||||
output += "<p><b><a href='byond://?src=\ref[src];showpoll=1'>Show Player Polls</A> (NEW!)</b></p>"
|
||||
else
|
||||
output += "<p><a href='byond://?src=\ref[src];showpoll=1'>Show Player Polls</A></p>"
|
||||
|
||||
output += "</center>"
|
||||
|
||||
//src << browse(output,"window=playersetup;size=210x240;can_close=0")
|
||||
var/datum/browser/popup = new(src, "playersetup", "<div align='center'>New Player Options</div>", 220, 265)
|
||||
popup.set_window_options("can_close=0")
|
||||
popup.set_content(output)
|
||||
popup.open(0)
|
||||
return
|
||||
|
||||
/mob/new_player/Stat()
|
||||
..()
|
||||
|
||||
if(statpanel("Lobby"))
|
||||
stat("Game Mode:", (ticker.hide_mode) ? "Secret" : "[master_mode]")
|
||||
stat("Map:", MAP_NAME)
|
||||
|
||||
if(ticker.current_state == GAME_STATE_PREGAME)
|
||||
stat("Time To Start:", (ticker.timeLeft >= 0) ? "[round(ticker.timeLeft / 10)]s" : "DELAYED")
|
||||
|
||||
stat("Players:", "[ticker.totalPlayers]")
|
||||
if(client.holder)
|
||||
stat("Players Ready:", "[ticker.totalPlayersReady]")
|
||||
|
||||
|
||||
/mob/new_player/Topic(href, href_list[])
|
||||
if(src != usr)
|
||||
return 0
|
||||
|
||||
if(!client)
|
||||
return 0
|
||||
|
||||
//Determines Relevent Population Cap
|
||||
var/relevant_cap
|
||||
if(config.hard_popcap && config.extreme_popcap)
|
||||
relevant_cap = min(config.hard_popcap, config.extreme_popcap)
|
||||
else
|
||||
relevant_cap = max(config.hard_popcap, config.extreme_popcap)
|
||||
|
||||
if(href_list["show_preferences"])
|
||||
client.prefs.ShowChoices(src)
|
||||
return 1
|
||||
|
||||
if(href_list["ready"])
|
||||
if(!ticker || ticker.current_state <= GAME_STATE_PREGAME) // Make sure we don't ready up after the round has started
|
||||
ready = text2num(href_list["ready"])
|
||||
else
|
||||
ready = 0
|
||||
|
||||
if(href_list["refresh"])
|
||||
src << browse(null, "window=playersetup") //closes the player setup window
|
||||
new_player_panel()
|
||||
|
||||
if(href_list["observe"])
|
||||
|
||||
if(alert(src,"Are you sure you wish to observe? You will not be able to play this round!","Player Setup","Yes","No") == "Yes")
|
||||
if(!client)
|
||||
return 1
|
||||
var/mob/dead/observer/observer = new()
|
||||
|
||||
spawning = 1
|
||||
|
||||
observer.started_as_observer = 1
|
||||
close_spawn_windows()
|
||||
var/obj/O = locate("landmark*Observer-Start")
|
||||
src << "<span class='notice'>Now teleporting.</span>"
|
||||
if (O)
|
||||
observer.loc = O.loc
|
||||
else
|
||||
src << "<span class='notice'>Teleporting failed. You should be able to use ghost verbs to teleport somewhere useful</span>"
|
||||
observer.key = key
|
||||
observer.client = client
|
||||
observer.set_ghost_appearance()
|
||||
if(observer.client && observer.client.prefs)
|
||||
observer.real_name = observer.client.prefs.real_name
|
||||
observer.name = observer.real_name
|
||||
observer.update_icon()
|
||||
observer.stopLobbySound()
|
||||
qdel(mind)
|
||||
|
||||
qdel(src)
|
||||
return 1
|
||||
|
||||
if(href_list["late_join"])
|
||||
if(!ticker || ticker.current_state != GAME_STATE_PLAYING)
|
||||
usr << "<span class='danger'>The round is either not ready, or has already finished...</span>"
|
||||
return
|
||||
|
||||
if(href_list["late_join"] == "override")
|
||||
LateChoices()
|
||||
return
|
||||
|
||||
if(ticker.queued_players.len || (relevant_cap && living_player_count() >= relevant_cap && !(ckey(key) in admin_datums)))
|
||||
usr << "<span class='danger'>[config.hard_popcap_message]</span>"
|
||||
|
||||
var/queue_position = ticker.queued_players.Find(usr)
|
||||
if(queue_position == 1)
|
||||
usr << "<span class='notice'>You are next in line to join the game. You will be notified when a slot opens up.</span>"
|
||||
else if(queue_position)
|
||||
usr << "<span class='notice'>There are [queue_position-1] players in front of you in the queue to join the game.</span>"
|
||||
else
|
||||
ticker.queued_players += usr
|
||||
usr << "<span class='notice'>You have been added to the queue to join the game. Your position in queue is [ticker.queued_players.len].</span>"
|
||||
return
|
||||
LateChoices()
|
||||
|
||||
if(href_list["manifest"])
|
||||
ViewManifest()
|
||||
|
||||
if(href_list["SelectedJob"])
|
||||
|
||||
if(!enter_allowed)
|
||||
usr << "<span class='notice'>There is an administrative lock on entering the game!</span>"
|
||||
return
|
||||
|
||||
if(ticker.queued_players.len && !(ckey(key) in admin_datums))
|
||||
if((living_player_count() >= relevant_cap) || (src != ticker.queued_players[1]))
|
||||
usr << "<span class='warning'>Server is full.</span>"
|
||||
return
|
||||
|
||||
AttemptLateSpawn(href_list["SelectedJob"])
|
||||
return
|
||||
|
||||
if(!ready && href_list["preference"])
|
||||
if(client)
|
||||
client.prefs.process_link(src, href_list)
|
||||
else if(!href_list["late_join"])
|
||||
new_player_panel()
|
||||
|
||||
if(href_list["showpoll"])
|
||||
handle_player_polling()
|
||||
return
|
||||
|
||||
if(href_list["pollid"])
|
||||
var/pollid = href_list["pollid"]
|
||||
if(istext(pollid))
|
||||
pollid = text2num(pollid)
|
||||
if(isnum(pollid) && IsInteger(pollid))
|
||||
src.poll_player(pollid)
|
||||
return
|
||||
|
||||
if(href_list["votepollid"] && href_list["votetype"])
|
||||
var/pollid = text2num(href_list["votepollid"])
|
||||
var/votetype = href_list["votetype"]
|
||||
switch(votetype)
|
||||
if(POLLTYPE_OPTION)
|
||||
var/optionid = text2num(href_list["voteoptionid"])
|
||||
if(vote_on_poll(pollid, optionid))
|
||||
usr << "<span class='notice'>Vote successful.</span>"
|
||||
else
|
||||
usr << "<span class='danger'>Vote failed, please try again or contact an administrator.</span>"
|
||||
if(POLLTYPE_TEXT)
|
||||
var/replytext = href_list["replytext"]
|
||||
if(log_text_poll_reply(pollid, replytext))
|
||||
usr << "<span class='notice'>Feedback logging successful.</span>"
|
||||
else
|
||||
usr << "<span class='danger'>Feedback logging failed, please try again or contact an administrator.</span>"
|
||||
if(POLLTYPE_RATING)
|
||||
var/id_min = text2num(href_list["minid"])
|
||||
var/id_max = text2num(href_list["maxid"])
|
||||
|
||||
if( (id_max - id_min) > 100 ) //Basic exploit prevention
|
||||
usr << "The option ID difference is too big. Please contact administration or the database admin."
|
||||
return
|
||||
|
||||
for(var/optionid = id_min; optionid <= id_max; optionid++)
|
||||
if(!isnull(href_list["o[optionid]"])) //Test if this optionid was replied to
|
||||
var/rating
|
||||
if(href_list["o[optionid]"] == "abstain")
|
||||
rating = null
|
||||
else
|
||||
rating = text2num(href_list["o[optionid]"])
|
||||
if(!isnum(rating) || !IsInteger(rating))
|
||||
return
|
||||
|
||||
if(!vote_on_numval_poll(pollid, optionid, rating))
|
||||
usr << "<span class='danger'>Vote failed, please try again or contact an administrator.</span>"
|
||||
return
|
||||
usr << "<span class='notice'>Vote successful.</span>"
|
||||
if(POLLTYPE_MULTI)
|
||||
var/id_min = text2num(href_list["minoptionid"])
|
||||
var/id_max = text2num(href_list["maxoptionid"])
|
||||
|
||||
if( (id_max - id_min) > 100 ) //Basic exploit prevention
|
||||
usr << "The option ID difference is too big. Please contact administration or the database admin."
|
||||
return
|
||||
|
||||
for(var/optionid = id_min; optionid <= id_max; optionid++)
|
||||
if(!isnull(href_list["option_[optionid]"])) //Test if this optionid was selected
|
||||
var/i = vote_on_multi_poll(pollid, optionid)
|
||||
switch(i)
|
||||
if(0)
|
||||
continue
|
||||
if(1)
|
||||
usr << "<span class='danger'>Vote failed, please try again or contact an administrator.</span>"
|
||||
return
|
||||
if(2)
|
||||
usr << "<span class='danger'>Maximum replies reached.</span>"
|
||||
break
|
||||
usr << "<span class='notice'>Vote successful.</span>"
|
||||
|
||||
/mob/new_player/proc/IsJobAvailable(rank)
|
||||
var/datum/job/job = SSjob.GetJob(rank)
|
||||
if(!job)
|
||||
return 0
|
||||
if((job.current_positions >= job.total_positions) && job.total_positions != -1)
|
||||
if(job.title == "Assistant")
|
||||
if(isnum(client.player_age) && client.player_age <= 14) //Newbies can always be assistants
|
||||
return 1
|
||||
for(var/datum/job/J in SSjob.occupations)
|
||||
if(J && J.current_positions < J.total_positions && J.title != job.title)
|
||||
return 0
|
||||
else
|
||||
return 0
|
||||
if(jobban_isbanned(src,rank))
|
||||
return 0
|
||||
if(!job.player_old_enough(src.client))
|
||||
return 0
|
||||
if(config.enforce_human_authority && !client.prefs.pref_species.qualifies_for_rank(rank, client.prefs.features))
|
||||
return 0
|
||||
return 1
|
||||
|
||||
|
||||
/mob/new_player/proc/AttemptLateSpawn(rank)
|
||||
if(!IsJobAvailable(rank))
|
||||
src << alert("[rank] is not available. Please try another.")
|
||||
return 0
|
||||
|
||||
//Remove the player from the join queue if he was in one and reset the timer
|
||||
ticker.queued_players -= src
|
||||
ticker.queue_delay = 4
|
||||
|
||||
SSjob.AssignRole(src, rank, 1)
|
||||
|
||||
var/mob/living/carbon/human/character = create_character() //creates the human and transfers vars and mind
|
||||
SSjob.EquipRank(character, rank, 1) //equips the human
|
||||
|
||||
var/D = pick(latejoin)
|
||||
if(!D)
|
||||
for(var/turf/T in get_area_turfs(/area/shuttle/arrival))
|
||||
if(!T.density)
|
||||
var/clear = 1
|
||||
for(var/obj/O in T)
|
||||
if(O.density)
|
||||
clear = 0
|
||||
break
|
||||
if(clear)
|
||||
D = T
|
||||
continue
|
||||
|
||||
character.loc = D
|
||||
|
||||
if(character.mind.assigned_role != "Cyborg")
|
||||
data_core.manifest_inject(character)
|
||||
ticker.minds += character.mind//Cyborgs and AIs handle this in the transform proc. //TODO!!!!! ~Carn
|
||||
AnnounceArrival(character, rank)
|
||||
AddEmploymentContract(character)
|
||||
else
|
||||
character.Robotize()
|
||||
|
||||
joined_player_list += character.ckey
|
||||
|
||||
if(config.allow_latejoin_antagonists)
|
||||
switch(SSshuttle.emergency.mode)
|
||||
if(SHUTTLE_RECALL, SHUTTLE_IDLE)
|
||||
ticker.mode.make_antag_chance(character)
|
||||
if(SHUTTLE_CALL)
|
||||
if(SSshuttle.emergency.timeLeft(1) > initial(SSshuttle.emergencyCallTime)*0.5)
|
||||
ticker.mode.make_antag_chance(character)
|
||||
qdel(src)
|
||||
|
||||
/mob/new_player/proc/AnnounceArrival(var/mob/living/carbon/human/character, var/rank)
|
||||
if(ticker.current_state != GAME_STATE_PLAYING)
|
||||
return
|
||||
var/area/A = get_area(character)
|
||||
var/message = "<span class='game deadsay'><span class='name'>\
|
||||
[character.real_name]</span> ([rank]) has arrived at the station at \
|
||||
<span class='name'>[A.name]</span>.</span>"
|
||||
deadchat_broadcast(message, follow_target = character, message_type=DEADCHAT_ARRIVALRATTLE)
|
||||
if((!announcement_systems.len) || (!character.mind))
|
||||
return
|
||||
if((character.mind.assigned_role == "Cyborg") || (character.mind.assigned_role == character.mind.special_role))
|
||||
return
|
||||
|
||||
var/obj/machinery/announcement_system/announcer = pick(announcement_systems)
|
||||
announcer.announce("ARRIVAL", character.real_name, rank, list()) //make the list empty to make it announce it in common
|
||||
|
||||
/mob/new_player/proc/AddEmploymentContract(mob/living/carbon/human/employee)
|
||||
//TODO: figure out a way to exclude wizards/nukeops/demons from this.
|
||||
sleep(30)
|
||||
for(var/C in employmentCabinets)
|
||||
var/obj/structure/filingcabinet/employment/employmentCabinet = C
|
||||
if(!employmentCabinet.virgin)
|
||||
employmentCabinet.addFile(employee)
|
||||
|
||||
|
||||
/mob/new_player/proc/LateChoices()
|
||||
var/mills = world.time // 1/10 of a second, not real milliseconds but whatever
|
||||
//var/secs = ((mills % 36000) % 600) / 10 //Not really needed, but I'll leave it here for refrence.. or something
|
||||
var/mins = (mills % 36000) / 600
|
||||
var/hours = mills / 36000
|
||||
|
||||
var/dat = "<div class='notice'>Round Duration: [round(hours)]h [round(mins)]m</div>"
|
||||
|
||||
switch(SSshuttle.emergency.mode)
|
||||
if(SHUTTLE_ESCAPE)
|
||||
dat += "<div class='notice red'>The station has been evacuated.</div><br>"
|
||||
if(SHUTTLE_CALL)
|
||||
if(!SSshuttle.canRecall())
|
||||
dat += "<div class='notice red'>The station is currently undergoing evacuation procedures.</div><br>"
|
||||
|
||||
var/available_job_count = 0
|
||||
for(var/datum/job/job in SSjob.occupations)
|
||||
if(job && IsJobAvailable(job.title))
|
||||
available_job_count++;
|
||||
|
||||
dat += "<div class='clearBoth'>Choose from the following open positions:</div><br>"
|
||||
dat += "<div class='jobs'><div class='jobsColumn'>"
|
||||
var/job_count = 0
|
||||
for(var/datum/job/job in SSjob.occupations)
|
||||
if(job && IsJobAvailable(job.title))
|
||||
job_count++;
|
||||
if (job_count > round(available_job_count / 2))
|
||||
dat += "</div><div class='jobsColumn'>"
|
||||
var/position_class = "otherPosition"
|
||||
if (job.title in command_positions)
|
||||
position_class = "commandPosition"
|
||||
dat += "<a class='[position_class]' href='byond://?src=\ref[src];SelectedJob=[job.title]'>[job.title] ([job.current_positions])</a><br>"
|
||||
if(!job_count) //if there's nowhere to go, assistant opens up.
|
||||
for(var/datum/job/job in SSjob.occupations)
|
||||
if(job.title != "Assistant") continue
|
||||
dat += "<a class='otherPosition' href='byond://?src=\ref[src];SelectedJob=[job.title]'>[job.title] ([job.current_positions])</a><br>"
|
||||
break
|
||||
dat += "</div></div>"
|
||||
|
||||
// Removing the old window method but leaving it here for reference
|
||||
//src << browse(dat, "window=latechoices;size=300x640;can_close=1")
|
||||
|
||||
// Added the new browser window method
|
||||
var/datum/browser/popup = new(src, "latechoices", "Choose Profession", 440, 500)
|
||||
popup.add_stylesheet("playeroptions", 'html/browser/playeroptions.css')
|
||||
popup.set_content(dat)
|
||||
popup.open(0) // 0 is passed to open so that it doesn't use the onclose() proc
|
||||
|
||||
|
||||
/mob/new_player/proc/create_character()
|
||||
spawning = 1
|
||||
close_spawn_windows()
|
||||
|
||||
var/mob/living/carbon/human/new_character = new(loc)
|
||||
|
||||
if(config.force_random_names || appearance_isbanned(src))
|
||||
client.prefs.random_character()
|
||||
client.prefs.real_name = client.prefs.pref_species.random_name(gender,1)
|
||||
client.prefs.copy_to(new_character)
|
||||
new_character.dna.update_dna_identity()
|
||||
if(mind)
|
||||
mind.active = 0 //we wish to transfer the key manually
|
||||
mind.transfer_to(new_character) //won't transfer key since the mind is not active
|
||||
|
||||
new_character.name = real_name
|
||||
|
||||
new_character.key = key //Manually transfer the key to log them in
|
||||
new_character.stopLobbySound()
|
||||
|
||||
return new_character
|
||||
|
||||
/mob/new_player/proc/ViewManifest()
|
||||
var/dat = "<html><body>"
|
||||
dat += "<h4>Crew Manifest</h4>"
|
||||
dat += data_core.get_manifest(OOC = 1)
|
||||
|
||||
src << browse(dat, "window=manifest;size=387x420;can_close=1")
|
||||
|
||||
/mob/new_player/Move()
|
||||
return 0
|
||||
|
||||
|
||||
/mob/new_player/proc/close_spawn_windows()
|
||||
|
||||
src << browse(null, "window=latechoices") //closes late choices window
|
||||
src << browse(null, "window=playersetup") //closes the player setup window
|
||||
src << browse(null, "window=preferences") //closes job selection
|
||||
src << browse(null, "window=mob_occupation")
|
||||
src << browse(null, "window=latechoices") //closes late job selection
|
||||
@@ -0,0 +1,341 @@
|
||||
/datum/polloption
|
||||
var/optionid
|
||||
var/optiontext
|
||||
|
||||
/mob/new_player/proc/handle_player_polling()
|
||||
if(!dbcon.IsConnected())
|
||||
usr << "<span class='danger'>Failed to establish database connection.</span>"
|
||||
return
|
||||
var/DBQuery/query_get_poll = dbcon.NewQuery("SELECT id, question FROM [format_table_name("poll_question")] WHERE [(client.holder ? "" : "adminonly = false AND")] Now() BETWEEN starttime AND endtime")
|
||||
if(!query_get_poll.Execute())
|
||||
var/err = query_get_poll.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining id, question from poll_question table. Error : \[[err]\]\n")
|
||||
return
|
||||
var/output = "<div align='center'><B>Player polls</B><hr><table>"
|
||||
var/i = 0
|
||||
while(query_get_poll.NextRow())
|
||||
var/pollid = query_get_poll.item[1]
|
||||
var/pollquestion = query_get_poll.item[2]
|
||||
output += "<tr bgcolor='#[ (i % 2 == 1) ? "e2e2e2" : "e2e2e2" ]'><td><a href=\"byond://?src=\ref[src];pollid=[pollid]\"><b>[pollquestion]</b></a></td></tr>"
|
||||
i++
|
||||
output += "</table>"
|
||||
src << browse(output,"window=playerpolllist;size=500x300")
|
||||
|
||||
/mob/new_player/proc/poll_player(pollid)
|
||||
if(!pollid)
|
||||
return
|
||||
if(!dbcon.IsConnected())
|
||||
usr << "<span class='danger'>Failed to establish database connection.</span>"
|
||||
return
|
||||
var/DBQuery/select_query = dbcon.NewQuery("SELECT starttime, endtime, question, polltype, multiplechoiceoptions FROM [format_table_name("poll_question")] WHERE id = [pollid]")
|
||||
if(!select_query.Execute())
|
||||
var/err = select_query.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining starttime, endtime, question, polltype, multiplechoiceoptions from poll_question table. Error : \[[err]\]\n")
|
||||
return
|
||||
var/pollstarttime = ""
|
||||
var/pollendtime = ""
|
||||
var/pollquestion = ""
|
||||
var/polltype = ""
|
||||
var/multiplechoiceoptions = 0
|
||||
if(select_query.NextRow())
|
||||
pollstarttime = select_query.item[1]
|
||||
pollendtime = select_query.item[2]
|
||||
pollquestion = select_query.item[3]
|
||||
polltype = select_query.item[4]
|
||||
multiplechoiceoptions = text2num(select_query.item[5])
|
||||
switch(polltype)
|
||||
if(POLLTYPE_OPTION)
|
||||
var/DBQuery/voted_query = dbcon.NewQuery("SELECT optionid FROM [format_table_name("poll_vote")] WHERE pollid = [pollid] AND ckey = '[ckey]'")
|
||||
if(!voted_query.Execute())
|
||||
var/err = voted_query.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining optionid from poll_vote table. Error : \[[err]\]\n")
|
||||
return
|
||||
var/votedoptionid = 0
|
||||
if(voted_query.NextRow())
|
||||
votedoptionid = text2num(voted_query.item[1])
|
||||
var/list/datum/polloption/options = list()
|
||||
var/DBQuery/options_query = dbcon.NewQuery("SELECT id, text FROM [format_table_name("poll_option")] WHERE pollid = [pollid]")
|
||||
if(!options_query.Execute())
|
||||
var/err = options_query.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining id, text from poll_option table. Error : \[[err]\]\n")
|
||||
return
|
||||
while(options_query.NextRow())
|
||||
var/datum/polloption/PO = new()
|
||||
PO.optionid = text2num(options_query.item[1])
|
||||
PO.optiontext = options_query.item[2]
|
||||
options += PO
|
||||
var/output = "<div align='center'><B>Player poll</B><hr>"
|
||||
output += "<b>Question: [pollquestion]</b><br>"
|
||||
output += "<font size='2'>Poll runs from <b>[pollstarttime]</b> until <b>[pollendtime]</b></font><p>"
|
||||
if(!votedoptionid)
|
||||
output += "<form name='cardcomp' action='?src=\ref[src]' method='get'>"
|
||||
output += "<input type='hidden' name='src' value='\ref[src]'>"
|
||||
output += "<input type='hidden' name='votepollid' value='[pollid]'>"
|
||||
output += "<input type='hidden' name='votetype' value=[POLLTYPE_OPTION]>"
|
||||
output += "<table><tr><td>"
|
||||
for(var/datum/polloption/O in options)
|
||||
if(O.optionid && O.optiontext)
|
||||
if(votedoptionid)
|
||||
if(votedoptionid == O.optionid)
|
||||
output += "<b>[O.optiontext]</b><br>"
|
||||
else
|
||||
output += "[O.optiontext]<br>"
|
||||
else
|
||||
output += "<input type='radio' name='voteoptionid' value='[O.optionid]'>[O.optiontext]<br>"
|
||||
output += "</td></tr></table>"
|
||||
if(!votedoptionid)
|
||||
output += "<p><input type='submit' value='Vote'>"
|
||||
output += "</form>"
|
||||
output += "</div>"
|
||||
src << browse(output,"window=playerpoll;size=500x250")
|
||||
if(POLLTYPE_TEXT)
|
||||
var/DBQuery/voted_query = dbcon.NewQuery("SELECT replytext FROM [format_table_name("poll_textreply")] WHERE pollid = [pollid] AND ckey = '[ckey]'")
|
||||
if(!voted_query.Execute())
|
||||
var/err = voted_query.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining replytext from poll_textreply table. Error : \[[err]\]\n")
|
||||
return
|
||||
var/vote_text = ""
|
||||
if(voted_query.NextRow())
|
||||
vote_text = voted_query.item[1]
|
||||
var/output = "<div align='center'><B>Player poll</B><hr>"
|
||||
output += "<b>Question: [pollquestion]</b><br>"
|
||||
output += "<font size='2'>Feedback gathering runs from <b>[pollstarttime]</b> until <b>[pollendtime]</b></font><p>"
|
||||
if(!vote_text)
|
||||
output += "<form name='cardcomp' action='?src=\ref[src]' method='get'>"
|
||||
output += "<input type='hidden' name='src' value='\ref[src]'>"
|
||||
output += "<input type='hidden' name='votepollid' value='[pollid]'>"
|
||||
output += "<input type='hidden' name='votetype' value=[POLLTYPE_TEXT]>"
|
||||
output += "<font size='2'>Please provide feedback below. You can use any letters of the English alphabet, numbers and the symbols: . , ! ? : ; -</font><br>"
|
||||
output += "<textarea name='replytext' cols='50' rows='14'></textarea>"
|
||||
output += "<p><input type='submit' value='Submit'></form>"
|
||||
output += "<form name='cardcomp' action='?src=\ref[src]' method='get'>"
|
||||
output += "<input type='hidden' name='src' value='\ref[src]'>"
|
||||
output += "<input type='hidden' name='votepollid' value='[pollid]'>"
|
||||
output += "<input type='hidden' name='votetype' value=[POLLTYPE_TEXT]>"
|
||||
output += "<input type='hidden' name='replytext' value='ABSTAIN'>"
|
||||
output += "<input type='submit' value='Abstain'></form>"
|
||||
else
|
||||
vote_text = replacetext(vote_text, "\n", "<br>")
|
||||
output += "[vote_text]"
|
||||
src << browse(output,"window=playerpoll;size=500x500")
|
||||
if(POLLTYPE_RATING)
|
||||
var/DBQuery/voted_query = dbcon.NewQuery("SELECT o.text, v.rating FROM [format_table_name("poll_option")] o, [format_table_name("poll_vote")] v WHERE o.pollid = [pollid] AND v.ckey = '[ckey]' AND o.id = v.optionid")
|
||||
if(!voted_query.Execute())
|
||||
var/err = voted_query.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining o.text, v.rating from poll_option and poll_vote tables. Error : \[[err]\]\n")
|
||||
return
|
||||
var/output = "<div align='center'><B>Player poll</B><hr>"
|
||||
output += "<b>Question: [pollquestion]</b><br>"
|
||||
output += "<font size='2'>Poll runs from <b>[pollstarttime]</b> until <b>[pollendtime]</b></font><p>"
|
||||
var/rating
|
||||
while(voted_query.NextRow())
|
||||
var/optiontext = voted_query.item[1]
|
||||
rating = voted_query.item[2]
|
||||
output += "<br><b>[optiontext] - [rating]</b>"
|
||||
if(!rating)
|
||||
output += "<form name='cardcomp' action='?src=\ref[src]' method='get'>"
|
||||
output += "<input type='hidden' name='src' value='\ref[src]'>"
|
||||
output += "<input type='hidden' name='votepollid' value='[pollid]'>"
|
||||
output += "<input type='hidden' name='votetype' value=[POLLTYPE_RATING]>"
|
||||
var/minid = 999999
|
||||
var/maxid = 0
|
||||
var/DBQuery/option_query = dbcon.NewQuery("SELECT id, text, minval, maxval, descmin, descmid, descmax FROM [format_table_name("poll_option")] WHERE pollid = [pollid]")
|
||||
if(!option_query.Execute())
|
||||
var/err = option_query.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining id, text, minval, maxval, descmin, descmid, descmax from poll_option table. Error : \[[err]\]\n")
|
||||
return
|
||||
while(option_query.NextRow())
|
||||
var/optionid = text2num(option_query.item[1])
|
||||
var/optiontext = option_query.item[2]
|
||||
var/minvalue = text2num(option_query.item[3])
|
||||
var/maxvalue = text2num(option_query.item[4])
|
||||
var/descmin = option_query.item[5]
|
||||
var/descmid = option_query.item[6]
|
||||
var/descmax = option_query.item[7]
|
||||
if(optionid < minid)
|
||||
minid = optionid
|
||||
if(optionid > maxid)
|
||||
maxid = optionid
|
||||
var/midvalue = round( (maxvalue + minvalue) / 2)
|
||||
output += "<br>[optiontext]: <select name='o[optionid]'>"
|
||||
output += "<option value='abstain'>abstain</option>"
|
||||
for (var/j = minvalue; j <= maxvalue; j++)
|
||||
if(j == minvalue && descmin)
|
||||
output += "<option value='[j]'>[j] ([descmin])</option>"
|
||||
else if (j == midvalue && descmid)
|
||||
output += "<option value='[j]'>[j] ([descmid])</option>"
|
||||
else if (j == maxvalue && descmax)
|
||||
output += "<option value='[j]'>[j] ([descmax])</option>"
|
||||
else
|
||||
output += "<option value='[j]'>[j]</option>"
|
||||
output += "</select>"
|
||||
output += "<input type='hidden' name='minid' value='[minid]'>"
|
||||
output += "<input type='hidden' name='maxid' value='[maxid]'>"
|
||||
output += "<p><input type='submit' value='Submit'></form>"
|
||||
src << browse(output,"window=playerpoll;size=500x500")
|
||||
if(POLLTYPE_MULTI)
|
||||
var/DBQuery/voted_query = dbcon.NewQuery("SELECT optionid FROM [format_table_name("poll_vote")] WHERE pollid = [pollid] AND ckey = '[ckey]'")
|
||||
if(!voted_query.Execute())
|
||||
var/err = voted_query.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining optionid from poll_vote table. Error : \[[err]\]\n")
|
||||
return
|
||||
var/list/votedfor = list()
|
||||
while(voted_query.NextRow())
|
||||
votedfor.Add(text2num(voted_query.item[1]))
|
||||
var/list/datum/polloption/options = list()
|
||||
var/maxoptionid = 0
|
||||
var/minoptionid = 0
|
||||
var/DBQuery/options_query = dbcon.NewQuery("SELECT id, text FROM [format_table_name("poll_option")] WHERE pollid = [pollid]")
|
||||
if(!options_query.Execute())
|
||||
var/err = options_query.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining id, text from poll_option table. Error : \[[err]\]\n")
|
||||
return
|
||||
while(options_query.NextRow())
|
||||
var/datum/polloption/PO = new()
|
||||
PO.optionid = text2num(options_query.item[1])
|
||||
PO.optiontext = options_query.item[2]
|
||||
if(PO.optionid > maxoptionid)
|
||||
maxoptionid = PO.optionid
|
||||
if(PO.optionid < minoptionid || !minoptionid)
|
||||
minoptionid = PO.optionid
|
||||
options += PO
|
||||
var/output = "<div align='center'><B>Player poll</B><hr>"
|
||||
output += "<b>Question: [pollquestion]</b><br>You can select up to [multiplechoiceoptions] options. If you select more, the first [multiplechoiceoptions] will be saved.<br>"
|
||||
output += "<font size='2'>Poll runs from <b>[pollstarttime]</b> until <b>[pollendtime]</b></font><p>"
|
||||
if(!votedfor.len)
|
||||
output += "<form name='cardcomp' action='?src=\ref[src]' method='get'>"
|
||||
output += "<input type='hidden' name='src' value='\ref[src]'>"
|
||||
output += "<input type='hidden' name='votepollid' value='[pollid]'>"
|
||||
output += "<input type='hidden' name='votetype' value=[POLLTYPE_MULTI]>"
|
||||
output += "<input type='hidden' name='maxoptionid' value='[maxoptionid]'>"
|
||||
output += "<input type='hidden' name='minoptionid' value='[minoptionid]'>"
|
||||
output += "<table><tr><td>"
|
||||
for(var/datum/polloption/O in options)
|
||||
if(O.optionid && O.optiontext)
|
||||
if(votedfor.len)
|
||||
if(O.optionid in votedfor)
|
||||
output += "<b>[O.optiontext]</b><br>"
|
||||
else
|
||||
output += "[O.optiontext]<br>"
|
||||
else
|
||||
output += "<input type='checkbox' name='option_[O.optionid]' value='[O.optionid]'>[O.optiontext]<br>"
|
||||
output += "</td></tr></table>"
|
||||
if(!votedfor.len)
|
||||
output += "<p><input type='submit' value='Vote'></form>"
|
||||
output += "</div>"
|
||||
src << browse(output,"window=playerpoll;size=500x250")
|
||||
return
|
||||
|
||||
/mob/new_player/proc/poll_check_voted(pollid, table)
|
||||
if(!dbcon.IsConnected())
|
||||
usr << "<span class='danger'>Failed to establish database connection.</span>"
|
||||
return
|
||||
var/DBQuery/query_hasvoted = dbcon.NewQuery("SELECT id FROM [format_table_name(table)] WHERE pollid = [pollid] AND ckey = '[ckey]'")
|
||||
if(!query_hasvoted.Execute())
|
||||
var/err = query_hasvoted.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining id from [table] table. Error : \[[err]\]\n")
|
||||
return
|
||||
if(query_hasvoted.NextRow())
|
||||
usr << "<span class='danger'>You've already replied to this poll.</span>"
|
||||
return
|
||||
. = "Player"
|
||||
if(client.holder)
|
||||
. = client.holder.rank
|
||||
return .
|
||||
|
||||
/mob/new_player/proc/vote_on_poll(pollid, optionid)
|
||||
if(!pollid || !optionid)
|
||||
return
|
||||
var/adminrank = poll_check_voted(pollid, "poll_vote")
|
||||
if(!adminrank)
|
||||
return
|
||||
var/DBQuery/query_insert = dbcon.NewQuery("INSERT INTO [format_table_name("poll_vote")] (datetime, pollid, optionid, ckey, ip, adminrank) VALUES (Now(), [pollid], [optionid], '[ckey]', '[client.address]', '[adminrank]')")
|
||||
if(!query_insert.Execute())
|
||||
var/err = query_insert.ErrorMsg()
|
||||
log_game("SQL ERROR adding vote to table. Error : \[[err]\]\n")
|
||||
return
|
||||
usr << browse(null,"window=playerpoll")
|
||||
return 1
|
||||
|
||||
/mob/new_player/proc/log_text_poll_reply(pollid, replytext)
|
||||
if(!pollid)
|
||||
return
|
||||
if(!replytext)
|
||||
usr << "The text you entered was blank. Please correct the text and submit again."
|
||||
return
|
||||
var/adminrank = poll_check_voted(pollid, "poll_textreply")
|
||||
if(!adminrank)
|
||||
return
|
||||
replytext = sanitizeSQL(replytext)
|
||||
if(!(length(replytext) > 0) || !(length(replytext) <= 8000))
|
||||
usr << "The text you entered was invalid or too long. Please correct the text and submit again."
|
||||
return
|
||||
var/DBQuery/query_insert = dbcon.NewQuery("INSERT INTO [format_table_name("poll_textreply")] (datetime ,pollid ,ckey ,ip ,replytext ,adminrank) VALUES (Now(), [pollid], '[ckey]', '[client.address]', '[replytext]', '[adminrank]')")
|
||||
if(!query_insert.Execute())
|
||||
var/err = query_insert.ErrorMsg()
|
||||
log_game("SQL ERROR adding text reply to table. Error : \[[err]\]\n")
|
||||
return
|
||||
usr << browse(null,"window=playerpoll")
|
||||
return 1
|
||||
|
||||
/mob/new_player/proc/vote_on_numval_poll(pollid, optionid, rating)
|
||||
if(!pollid || !optionid || !rating)
|
||||
return
|
||||
if(!dbcon.IsConnected())
|
||||
usr << "<span class='danger'>Failed to establish database connection.</span>"
|
||||
return
|
||||
var/DBQuery/query_hasvoted = dbcon.NewQuery("SELECT id FROM [format_table_name("poll_vote")] WHERE optionid = [optionid] AND ckey = '[ckey]'")
|
||||
if(!query_hasvoted.Execute())
|
||||
var/err = query_hasvoted.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining id from poll_vote table. Error : \[[err]\]\n")
|
||||
return
|
||||
if(query_hasvoted.NextRow())
|
||||
usr << "<span class='danger'>You've already replied to this poll.</span>"
|
||||
return
|
||||
var/adminrank = "Player"
|
||||
if(client.holder)
|
||||
adminrank = client.holder.rank
|
||||
var/DBQuery/query_insert = dbcon.NewQuery("INSERT INTO [format_table_name("poll_vote")] (datetime ,pollid ,optionid ,ckey ,ip ,adminrank, rating) VALUES (Now(), [pollid], [optionid], '[ckey]', '[client.address]', '[adminrank]', [(isnull(rating)) ? "null" : rating])")
|
||||
if(!query_insert.Execute())
|
||||
var/err = query_insert.ErrorMsg()
|
||||
log_game("SQL ERROR adding vote to table. Error : \[[err]\]\n")
|
||||
return
|
||||
usr << browse(null,"window=playerpoll")
|
||||
return 1
|
||||
|
||||
/mob/new_player/proc/vote_on_multi_poll(pollid, optionid)
|
||||
if(!pollid || !optionid)
|
||||
return 1
|
||||
if(!dbcon.IsConnected())
|
||||
usr << "<span class='danger'>Failed to establish database connection.</span>"
|
||||
return 1
|
||||
var/DBQuery/query_get_choicelen = dbcon.NewQuery("SELECT multiplechoiceoptions FROM [format_table_name("poll_question")] WHERE id = [pollid]")
|
||||
if(!query_get_choicelen.Execute())
|
||||
var/err = query_get_choicelen.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining multiplechoiceoptions from poll_question table. Error : \[[err]\]\n")
|
||||
return 1
|
||||
var/i
|
||||
if(query_get_choicelen.NextRow())
|
||||
i = text2num(query_get_choicelen.item[1])
|
||||
var/DBQuery/query_hasvoted = dbcon.NewQuery("SELECT id FROM [format_table_name("poll_vote")] WHERE pollid = [pollid] AND ckey = '[ckey]'")
|
||||
if(!query_hasvoted.Execute())
|
||||
var/err = query_hasvoted.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining id from poll_vote table. Error : \[[err]\]\n")
|
||||
return 1
|
||||
while(i)
|
||||
if(query_hasvoted.NextRow())
|
||||
i--
|
||||
else
|
||||
break
|
||||
if(!i)
|
||||
return 2
|
||||
var/adminrank = "Player"
|
||||
if(client.holder)
|
||||
adminrank = client.holder.rank
|
||||
var/DBQuery/query_insert = dbcon.NewQuery("INSERT INTO [format_table_name("poll_vote")] (datetime, pollid, optionid, ckey, ip, adminrank) VALUES (Now(), [pollid], [optionid], '[ckey]', '[client.address]', '[adminrank]')")
|
||||
if(!query_insert.Execute())
|
||||
var/err = query_insert.ErrorMsg()
|
||||
log_game("SQL ERROR adding vote to table. Error : \[[err]\]\n")
|
||||
return 1
|
||||
usr << browse(null,"window=playerpoll")
|
||||
return 0
|
||||
@@ -0,0 +1,81 @@
|
||||
|
||||
//The mob should have a gender you want before running this proc. Will run fine without H
|
||||
/datum/preferences/proc/random_character(gender_override)
|
||||
if(gender_override)
|
||||
gender = gender_override
|
||||
else
|
||||
gender = pick(MALE,FEMALE)
|
||||
underwear = random_underwear(gender)
|
||||
undershirt = random_undershirt(gender)
|
||||
socks = random_socks()
|
||||
skin_tone = random_skin_tone()
|
||||
hair_style = random_hair_style(gender)
|
||||
facial_hair_style = random_facial_hair_style(gender)
|
||||
hair_color = random_short_color()
|
||||
facial_hair_color = hair_color
|
||||
eye_color = random_eye_color()
|
||||
if(!pref_species)
|
||||
var/rando_race = pick(config.roundstart_races)
|
||||
pref_species = new rando_race()
|
||||
backbag = 1
|
||||
features = random_features()
|
||||
age = rand(AGE_MIN,AGE_MAX)
|
||||
|
||||
/datum/preferences/proc/update_preview_icon()
|
||||
// Silicons only need a very basic preview since there is no customization for them.
|
||||
if(job_engsec_high)
|
||||
switch(job_engsec_high)
|
||||
if(AI)
|
||||
preview_icon = icon('icons/mob/AI.dmi', "AI", SOUTH)
|
||||
preview_icon.Scale(64, 64)
|
||||
return
|
||||
if(CYBORG)
|
||||
preview_icon = icon('icons/mob/robots.dmi', "robot", SOUTH)
|
||||
preview_icon.Scale(64, 64)
|
||||
return
|
||||
|
||||
// Set up the dummy for its photoshoot
|
||||
var/mob/living/carbon/human/dummy/mannequin = new()
|
||||
copy_to(mannequin)
|
||||
|
||||
// Determine what job is marked as 'High' priority, and dress them up as such.
|
||||
var/datum/job/previewJob
|
||||
var/highRankFlag = job_civilian_high | job_medsci_high | job_engsec_high
|
||||
|
||||
if(job_civilian_low & ASSISTANT)
|
||||
previewJob = SSjob.GetJob("Assistant")
|
||||
else if(highRankFlag)
|
||||
var/highDeptFlag
|
||||
if(job_civilian_high)
|
||||
highDeptFlag = CIVILIAN
|
||||
else if(job_medsci_high)
|
||||
highDeptFlag = MEDSCI
|
||||
else if(job_engsec_high)
|
||||
highDeptFlag = ENGSEC
|
||||
|
||||
for(var/datum/job/job in SSjob.occupations)
|
||||
if(job.flag == highRankFlag && job.department_flag == highDeptFlag)
|
||||
previewJob = job
|
||||
break
|
||||
|
||||
if(previewJob)
|
||||
mannequin.job = previewJob.title
|
||||
previewJob.equip(mannequin, TRUE)
|
||||
|
||||
preview_icon = icon('icons/effects/effects.dmi', "nothing")
|
||||
preview_icon.Scale(48+32, 16+32)
|
||||
|
||||
mannequin.setDir(NORTH)
|
||||
var/icon/stamp = getFlatIcon(mannequin)
|
||||
preview_icon.Blend(stamp, ICON_OVERLAY, 25, 17)
|
||||
|
||||
mannequin.setDir(WEST)
|
||||
stamp = getFlatIcon(mannequin)
|
||||
preview_icon.Blend(stamp, ICON_OVERLAY, 1, 9)
|
||||
|
||||
mannequin.setDir(SOUTH)
|
||||
stamp = getFlatIcon(mannequin)
|
||||
preview_icon.Blend(stamp, ICON_OVERLAY, 49, 1)
|
||||
|
||||
preview_icon.Scale(preview_icon.Width() * 2, preview_icon.Height() * 2) // Scaling here to prevent blurring in the browser.
|
||||
qdel(mannequin)
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user