From 3a9ad04e6bfa50f9ab5f91f6da3a36e7bae0a0e0 Mon Sep 17 00:00:00 2001 From: div0 Date: Sat, 19 Jan 2008 11:23:55 +0000 Subject: [PATCH] make use of DP_SV_SHUTDOWN git-svn-id: svn://svn.icculus.org/nexuiz/trunk@3187 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/server/extensions.qh | 66 +++++++++++++++++++++++++++++++++ data/qcsrc/server/g_world.qc | 28 +++++++++----- 2 files changed, 85 insertions(+), 9 deletions(-) diff --git a/data/qcsrc/server/extensions.qh b/data/qcsrc/server/extensions.qh index 192416d81..c73b5230d 100644 --- a/data/qcsrc/server/extensions.qh +++ b/data/qcsrc/server/extensions.qh @@ -795,6 +795,15 @@ float MOVE_WORLDONLY = 3; // //this is basically a poor man's garbage collection system for strings. +//DP_QC_VECTOANGLES_WITH_ROLL +//idea: LordHavoc +//darkplaces implementation: LordHavoc +//builtin definitions: +vector(vector forward, vector up) vectoangles2 = #51; // same number as vectoangles +//description: +//variant of vectoangles that takes an up vector to calculate roll angle (also uses this to calculate yaw correctly if the forward is straight up or straight down) +//note: just like normal vectoangles you need to negate the pitch of the returned angles if you want to feed them to makevectors or assign to self.v_angle + //DP_QC_VECTORVECTORS //idea: LordHavoc //darkplaces implementation: LordHavoc @@ -995,6 +1004,25 @@ void(vector org, string modelname, float startframe, float endframe, float frame //The first parameter provides the entities original contents, prior to the transition. The second parameter provides the new contents. //NOTE: If this field function is provided on an entity, the standard watersplash sound IS SUPPRESSED to allow for authors to create their own transition sounds. +//DP_SV_POINTSOUND +//idea: Dresk +//darkplaces implementation: Dresk +//builtin definitions: +void(vector origin, string sample, float volume, float attenuation) pointsound = #483; +//description: +//Similar to the standard QC sound function, this function takes an origin instead of an entity and omits the channel parameter. +// This allows sounds to be played at arbitrary origins without spawning entities. + +//DP_SV_ONENTITYNOSPAWNFUNCTION +//idea: Dresk +//darkplaces implementation: Dresk +//engine-called QC prototypes: +//void() SV_OnEntityNoSpawnFunction; +//description: +// This function is called whenever an entity on the server has no spawn function, and therefore has no defined QC behavior. +// You may as such dictate the behavior as to what happens to the entity. +// To mimic the engine's default behavior, simply call remove(self). + //DP_SV_MODELFLAGS_AS_EFFECTS //idea: LordHavoc, Dresk //darkplaces implementation: LordHavoc @@ -1539,6 +1567,27 @@ float(string s1, string s2, float len) strncmp = #228; float(string s1, string s2) strcasecmp = #229; float(string s1, string s2, float len) strncasecmp = #230; +//DP_CON_BESTWEAPON +//idea: many +//darkplaces implementation: div0 +//description: +//allows QC to register weapon properties for use by the bestweapon command, for mods that change required ammo count or type for the weapons +//it is done using console commands sent via stuffcmd: +// register_bestweapon quake +// register_bestweapon clear +// register_bestweapon +//for example, this is what Quake uses: +// register_bestweapon 1 1 4096 4096 6 0 // STAT_SHELLS is 6 +// register_bestweapon 2 2 1 1 6 1 +// register_bestweapon 3 3 2 2 6 1 +// register_bestweapon 4 4 4 4 7 1 // STAT_NAILS is 7 +// register_bestweapon 5 5 8 8 7 1 +// register_bestweapon 6 6 16 16 8 1 // STAT_ROCKETS is 8 +// register_bestweapon 7 7 32 32 8 1 +// register_bestweapon 8 8 64 64 9 1 // STAT_CELLS is 9 +//after each map client initialization, this is reset back to Quake settings. So you should send these data in ClientConnect. +//also, this extension introduces a new "cycleweapon" command to the user. + //DP_QC_STRINGBUFFERS //idea: ?? //darkplaces implementation: LordHavoc @@ -1554,9 +1603,26 @@ void(float bufhandle, float string_index, string str) bufstr_set = #467; float(float bufhandle, string str, float order) bufstr_add = #468; void(float bufhandle, float string_index) bufstr_free = #469; +//DP_QC_STRREPLACE +//idea: Sajt +//darkplaces implementation: Sajt +//builtin definitions: +string(string search, string replace, string subject) strreplace = #484; +string(string search, string replace, string subject) strireplace = #485; +//description: +//strreplace replaces all occurrences of 'search' with 'replace' in the string 'subject', and returns the result as a tempstring. +//strireplace does the same but uses case-insensitive matching of the 'search' term +// //DP_QC_CRC16 //idea: div0 //darkplaces implementation: div0 //Some hash function to build hash tables with. This has to be be the CRC-16-CCITT that is also required for the QuakeWorld download protocol. //When caseinsensitive is set, the CRC is calculated of the lower cased string. float(float caseinsensitive, string s, ...) crc16 = #494; + +//DP_SV_SHUTDOWN +//idea: div0 +//darkplaces implementation: div0 +//A function that gets called just before progs exit. To save persistent data from. +//It is not called on a crash or error. +//void SV_Shutdown(); diff --git a/data/qcsrc/server/g_world.qc b/data/qcsrc/server/g_world.qc index 5add1776d..52d3a9709 100644 --- a/data/qcsrc/server/g_world.qc +++ b/data/qcsrc/server/g_world.qc @@ -1,5 +1,6 @@ float SPAWNFLAG_NO_WAYPOINTS_FOR_ITEMS = 1; string redirection_target; +float world_initialized; string GetMapname(); string GetGametype(); @@ -236,6 +237,8 @@ void worldspawn (void) MapInfo_Enumerate(); MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), 1); #endif + + world_initialized = 1; } void light (void) @@ -458,9 +461,6 @@ void() GameResetCfg = localcmd("exec game_reset.cfg\n"); #endif - - Ban_SaveBans(); - db_save(ServerProgsDB, "server.db"); }; void() Map_Goto = @@ -628,9 +628,6 @@ string() GetNextMap = float() DoNextMapOverride = { - Ban_SaveBans(); - db_save(ServerProgsDB, "server.db"); - if(cvar("g_campaign")) { CampaignPostIntermission(); @@ -930,9 +927,6 @@ void() NextLevel = gameover = TRUE; - Ban_SaveBans(); - db_save(ServerProgsDB, "server.db"); - intermission_running = 1; // enforce a wait time before allowing changelevel @@ -2151,3 +2145,19 @@ float RedirectionThink() return TRUE; } + +void SV_Shutdown() +{ + if(world_initialized) + { + world_initialized = 0; + print("Saving persistent data...\n"); + Ban_SaveBans(); + db_save(ServerProgsDB, "server.db"); + print("done!\n"); + } + else + { + print("NOTE: crashed before even initializing the world, not saving persistent data\n"); + } +} -- 2.39.2