From 110008221779b33f8bd2b618674d896fed690c61 Mon Sep 17 00:00:00 2001 From: Adam Olsen Date: Mon, 23 Jul 2001 15:08:39 +0000 Subject: [PATCH] - added some items to BUGS and TODO - reworked map cycler so that it saves the map number to cf/nextmapnum, and restores it in case of a crash - add a cyclenow infokey, which causes the timelimit to be hit instantly. needed because the map cycling doesn't kick in until the timelimit is reached - add cf/mapcycle which contains the names of maps to be cycled (seperated by nuls). it overwrites the normal "exec qwmcycle/map1.cfg" behavior. - change the MOTD time to 15 seconds (from 24.2) - make mapcfg.cfg exec'd if mapcfg is enabled (so you can reset the config vars - add a thing to enable sv_gc if it's disabled. (I'm using string appending now) --- BUGS | 1 + TODO | 2 + client.qc | 168 ++++++++++++++++++++++++++++++++++++++++++------------ defs.qc | 9 ++- world.qc | 7 ++- 5 files changed, 150 insertions(+), 37 deletions(-) diff --git a/BUGS b/BUGS index 03d4562..b4a1514 100644 --- a/BUGS +++ b/BUGS @@ -2,3 +2,4 @@ - duplicate connects - the curse color is rejected by the color changing code - the map cycler (including if you set nmap) just sit there if it doesn't change map. instead, it should have failsafe behavior +- "has_sentry" should be a counter, not a flag (allows a second build if you hack and it gets roasted) diff --git a/TODO b/TODO index fcbdada..c9e54d3 100644 --- a/TODO +++ b/TODO @@ -10,3 +10,5 @@ I make sure team/color is cleared when a client connects o allow lay mode if purchased o various drop items o move from *preqcc to cpp +o add more variety to tinkering +o add a way to edit the respawn ammo entities diff --git a/client.qc b/client.qc index 30d83dc..c7bfeb2 100644 --- a/client.qc +++ b/client.qc @@ -966,12 +966,122 @@ void() SetCycleTimer = newmis.think = cycle_timer_think; }; -void() GotoNextMap = +float() GetNextMapNum = +{ + local float desc; + local string st; + local string infostring; + local float infonum; + + infostring = infokey (world, "n"); + infonum = stof(infostring); + + if (infostring != "") // always use info when available + return infonum; + + if (cvar("crudefile_quota") < 0) + return infonum; + + desc = cfopen("nextmapnum", "r"); + if (desc < 0) + return infonum; + + st = cfread(desc); + if (st == "") + { + cfclose(desc); + return infonum; + } + + cfclose(desc); + return stof(st); +}; + +void(float mapnum) SetNextMapNum = +{ + local float desc; + local string mapstring; + + mapstring = ftos (mapnum); + + if (cvar("crudefile_quota") >= 0) + { + desc = cfopen ("nextmapnum", "w"); + // if nextmapnum has a num in it, but we can't modify it.. stuck in a loop + if (desc >= 0) + { + cfwrite (desc, mapstring); + cfclose (desc); + } + } + + localcmd("serverinfo n \"\"\n"); // use localinfo instead + localcmd("localinfo n "); + localcmd(mapstring); + localcmd("\n"); +}; + +void() LoadNextMap = { local float nextlevel; - local string sl; - local entity te; local string cyc; + local float desc; + local float mapcount; + local string map; + + nextlevel = GetNextMapNum(); + nextlevel = nextlevel + 1; // next level + SetNextMapNum(nextlevel); + + // get count of maps + mapcount = 0; + desc = cfopen ("mapcycle", "r"); + while (cfread(desc) != "") + mapcount = mapcount + 1; + cfclose ("mapcycle"); + + if (mapcount > 0) + { + if (nextlevel > mapcount) + { + while (nextlevel > mapcount) + nextlevel = nextlevel - mapcount; + SetNextMapNum (nextlevel); + } + + desc = cfopen ("mapcycle", "r"); + local float i; + i = 0; + while (i < nextlevel) + { + i = i + 1; + map = cfread(desc); + } + if (map == "") + mapcount = 0; // fall back to old mapcycle method + else + localcmd ("map " + map + "\n"); + } + + if (mapcount == 0) + { + cyc = infokey(world, "cycledir"); + if ( cyc == string_null ) + cyc = "qwmcycle"; + + localcmd("exec "); + localcmd(cyc); + localcmd("/map"); + + localcmd(ftos(nextlevel)); + localcmd(".cfg\n"); + + already_chosen_map = #CYCLED; + } +}; + +void() GotoNextMap = +{ if (nextmap != mapname) { @@ -989,37 +1099,9 @@ void() GotoNextMap = //- OfN - super new map cycling code :) if (already_chosen_map == #FALSE) - { - // ------- - ------- // - sl = infokey(world, "n"); - nextlevel = stof(sl); + LoadNextMap(); - nextlevel = nextlevel + 1; // next level - sl = ftos(nextlevel); - localcmd("serverinfo n \"\"\n"); // use localinfo instead - localcmd("localinfo n "); - localcmd(sl); - localcmd("\n"); - - - // change map - cyc = infokey(world, "cycledir"); - if ( cyc == string_null ) - localcmd("exec qwmcycle/map"); - else - { - localcmd("exec "); - localcmd(cyc); - localcmd("/map"); - } //.................// - - localcmd(sl); - localcmd(".cfg\n"); - - already_chosen_map = #CYCLED; - } - - if (infokey(world, "n") == "0") + if (GetNextMapNum() == 0) already_chosen_map = #FALSE; if (already_chosen_map == #FALSE) // nothing was done yet, so set the damn timer.. @@ -2225,6 +2307,8 @@ void() NextLevel = o.nextthink = time + 0.1; }; +float cyclenow; + /* ============ CheckRules @@ -2234,9 +2318,23 @@ Exit deathmatch games upon conditions */ void() CheckRules = { - if (timelimit && time >= timelimit) + local string st; + st = infokey (world, "cyclenow"); + + if (!cyclenow && (st == "1" || st == "on")) + { + cyclenow = 1; + + localcmd ("serverinfo cyclenow \"\"\n"); + localcmd ("localinfo cyclenow \"\"\n"); + + dprint ("Cycling Map.\n"); + NextLevel (); - else if (fraglimit && self.frags >= fraglimit) + } + else if (cyclenow + || (timelimit && time >= timelimit) + || (fraglimit && self.frags >= fraglimit)) NextLevel (); }; diff --git a/defs.qc b/defs.qc index 937ccfb..1b2e4a1 100644 --- a/defs.qc +++ b/defs.qc @@ -842,6 +842,12 @@ void(vector where, float set) multicast = #82; // sends the temp message to a // of clients, possibly in PVS or PHS #endif void (entity ent, string key, string value) setinfokey = #102; +float (string path, string mode) cfopen = #103; +void (float desc) cfclose = #104; +string (float desc) cfread = #105; +float (float desc, string buf) cfwrite = #106; +float (float desc) cfeof = #107; +float () cfquota = #108; //============================================================================ @@ -1013,7 +1019,8 @@ float(entity targ, entity inflictor) CanDamage; .float weaponmode; // Used for multiple mode weapons //WK 152 Default, must be > 6. -#define MOTD_FINISHED 242 //Delay in 1/10th seconds for motd to show +//#define MOTD_FINISHED 242 //Delay in 1/10th seconds for motd to show +#define MOTD_FINISHED 150 .float motd; // Used to display MOTD .float current_menu; // is set to the number of the current menu, is 0 if they are not in a menu .float menu_count; // keeps track of display times for menus diff --git a/world.qc b/world.qc index 89898e4..ed8effb 100644 --- a/world.qc +++ b/world.qc @@ -193,13 +193,18 @@ void() worldspawn = if (st == "1" || st == "on") st = "mapcfg"; + localcmd("exec mapcfg.cfg\n"); // generic stuff + localcmd("exec \""); localcmd(st); localcmd("/"); - localcmd(infokey(world, "map")); // FIXME: this is safe chaining, right? + localcmd(infokey(world, "map")); localcmd(".cfg\"\n"); } + if (!cvar("sv_gc")) + cvar_set ("sv_gc", "10"); + // custom map attributes #ifndef QUAKE_WORLD if (self.model == "maps/e1m8.bsp")