/* Stellar Crisis module for Roxen (http://www.roxen.com/) Copyright (C)1996 by Sylvan Clebsch This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. You can contact the author, Sylvan Clebsch, via email at sylvan@gnu.ai.mit.edu or via paper mail at: Sylvan Clebsch 334 Hawthorne St. Palo Alto, CA 94301 You can also finger sylvan@gnu.ai.mit.edu for not very up to date info. This package should include this file, a support directory full of graphics and a brief instructions file. Good luck, you'll need it... */ #include #include #undef SC_DEBUG #define MAX_FD 250 inherit "module"; #ifdef ROXEN inherit "roxenlib"; #else inherit "spiderlib"; #endif /* Change this if any mods are done */ string version="2.8"; mapping d=([]); mapping p=([]); mapping top=([]); int last_admin=time(); /* fix: add Engineer to both lists */ string *all_tech=({"Attack", "Science", "Colony", "Stargate", "Cloaker", "Satellite", "Terraformer", "Troopship", "Doomsday", "Minefield", "Minesweeper", "Engineer"}); string *move_ships=({"Attack", "Science", "Colony", "Cloaker", "Terraformer", "Troopship", "Doomsday", "Minesweeper", "Engineer"}); mapping truceban; // empires that aren't allowed to truce. array register_module() { return ({ MODULE_LOCATION, "Stellar Crisis "+version, "This is the Stellar Crisis game module. The support directory must " "be mounted as a filesystem.", }); } #define RATIOS_LINE \ sprintf(\ ""\ ""\ "
Maintenance Ratio:"\ "%0.3fFuel Ratio:%0.3fTech Level:%0.1fTech Development:%0.3f
"\ "

", \ d[series][game]["p"][name]["min_r"],\ d[series][game]["p"][name]["fuel_r"],\ d[series][game]["p"][name]["tech"],\ d[series][game]["p"][name]["tech_d"]) static string mountpoint, html_dir, ad_name, ad_mail, ad_pass; static string dump_file, debug_file, faq_url, servername; static int aliens, avg_rsrc, home_rsrc, admin_inc, close_game; string query_location() { return mountpoint; } string query_name() { return "Mounted on "+mountpoint; } void debug(string data) { #ifdef SC_DEBUG // object debug_fp=clone((program)"/precompiled/file"); object debug_fp=clone((program)files.file); debug_fp->open(debug_file, "wac"); debug_fp->write(data+" "+ctime(time())); debug_fp->close(); #endif } #ifdef SC_DEBUG int fd_fail() { // object fp=clone((program)"/precompiled/file"); object fp=clone((program)files.file); if(fp=open("/tmp/sc_fd_test", "rwc")) fp->close(); if(!fp || fp->query_fd()>(MAX_FD-4)) return 1; return 0; } #endif string nctime(int time) { string t=ctime(time); return (t[0..(sizeof(t)-2)]); } string time_conv(int sec) { string *next=({}); int hrs = sec/3600; sec -= hrs*3600; int min = sec/60; sec -= min*60; if(hrs) next += ({ hrs+" hrs"}); if(min) next += ({ min+" min"}); if(sec) next += ({ sec+" sec"}); if(!sizeof(next)) next += ({sec+" sec"}); return(next*", "); } string header(string title) { return ("SC "+version+servername+ ": "+title+""+ ""+ "

\n"); } string gheader(string title, string name, string c_pass, string series, string game, string message) { int delay; string gotoDoc; string update = ""; string end_btns = ""; string missive=d[series][game]["p"][name]["missive"]; d[series][game]["p"][name]["missive"]=""; if(missive!="") missive="

"+missive+"
"; if (d[series][game]["u_cnt"] == 0) { delay = d[series][game]["u_first"]-time(); if (d[series][game]["full"] == 1) { end_btns = ""+ ""; if(title != "Info") update = "

Next update when another player has joined."; } else if(title != "Info") update = "

Next update in "+time_conv(delay) +"
"; } else { delay = d[series]["u_time"]+d[series][game]["u_last"]-time(); if(title != "Info") update = "

Next update in "+time_conv(delay) +"
"; } switch(title) { case "Info": gotoDoc = "'document.forms[0].elements[6].click()'"; break; case "Tech": gotoDoc = "'document.forms[0].elements[7].click()'"; break; case "Ships": gotoDoc = "'document.forms[0].elements[8].click()'"; break; case "Fleets": gotoDoc = "'document.forms[0].elements[9].click()'"; break; case "Build": gotoDoc = "'document.forms[0].elements[10].click()'"; break; case "Systems": gotoDoc = "'document.forms[0].elements[11].click()'"; break; case "Map": gotoDoc = "'document.forms[0].elements[12].click()'"; break; case "Diplomacy": gotoDoc = "'document.forms[0].elements[13].click()'"; break; default: gotoDoc = "'document.forms[0].elements[14].click()'"; } return (""+ "SC "+version+servername+": "+title+ sprintf(": %s %s", series, game)+""+ ""+ ""+ "\n"+ ""+ ""+ ""+ ""+ ""+ ""+"\n"+ "

"+name+" "+title+ sprintf(": %s %s", series, game)+"

"+update+ ""+ ""+ ""+ ""+ ""+ ""+ ""+ ""+ ""+ end_btns+"

"+message+""+missive+"

"+ "

\n

"); } string footer() { return ("


"+ "

"+ "Help is available
"+ "
"); } mapping no_op(string a) { return (["data": header("No Op")+ "

Action Defined but Unimplemented

"+ "Debug Output:

"+a+"

"+ footer(), "type":"text/html"]); } int id_check(string name, string c_pass) { if(!mappingp(p[name])) return 0; return(crypt((string)p[name]["pass"], c_pass)); } int admin_id_check(string name, string c_pass) { int match=crypt(ad_pass, c_pass); return(match | (name==ad_name)); } string disp_g_missive(string name) { string missive=p[name]["missive"]; p[name]["missive"]=""; if(missive!="") return("

"+missive+"
"); return(""); } string dip_word(int status) { switch(status) { case 0: return "War"; case 1: return "Truce"; case 2: return "Trade"; case 3: return "Alliance"; default: return "Unknown"; } } string dip_offer(int status, int new, int blood, int banished) { string offer=""; if(banished) status = 0; if(status>0) { offer+="