r3848 - in trunk/data: . qcsrc/client qcsrc/common qcsrc/server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Sun Jul 20 11:23:17 EDT 2008
Author: div0
Date: 2008-07-20 11:23:16 -0400 (Sun, 20 Jul 2008)
New Revision: 3848
Modified:
trunk/data/defaultNexuiz.cfg
trunk/data/qcsrc/client/Defs.qc
trunk/data/qcsrc/client/Main.qc
trunk/data/qcsrc/client/csqc_builtins.qc
trunk/data/qcsrc/client/main.qh
trunk/data/qcsrc/client/mapvoting.qc
trunk/data/qcsrc/client/pre.qh
trunk/data/qcsrc/client/progs.src
trunk/data/qcsrc/common/constants.qh
trunk/data/qcsrc/common/util.qc
trunk/data/qcsrc/common/util.qh
trunk/data/qcsrc/server/cl_client.qc
trunk/data/qcsrc/server/g_world.qc
trunk/data/qcsrc/server/miscfunctions.qc
trunk/data/qcsrc/server/sv_main.qc
Log:
g_maplist_votable_screenshot_dir: take map screenshots out of another dir; minor cleanups (like, merge random selections, add DB support to CSQC)
Modified: trunk/data/defaultNexuiz.cfg
===================================================================
--- trunk/data/defaultNexuiz.cfg 2008-07-19 19:54:01 UTC (rev 3847)
+++ trunk/data/defaultNexuiz.cfg 2008-07-20 15:23:16 UTC (rev 3848)
@@ -814,6 +814,7 @@
seta g_maplist_votable_suggestions_override_mostrecent 0
seta g_maplist_votable_nodetail 0 // nodetail only shows total count instead of all vote counts per map, so votes don't influence others that much
seta g_maplist_votable_abstain 0 // when 1, you can abstain from your vote
+seta g_maplist_votable_screenshot_dir "maps" // where to look for map screenshots
seta g_maplist_textonly 0 // use old style centerprint
alias suggestmap "cmd suggestmap $1"
Modified: trunk/data/qcsrc/client/Defs.qc
===================================================================
--- trunk/data/qcsrc/client/Defs.qc 2008-07-19 19:54:01 UTC (rev 3847)
+++ trunk/data/qcsrc/client/Defs.qc 2008-07-20 15:23:16 UTC (rev 3848)
@@ -10,7 +10,6 @@
-#define CSQC 1
/*
==============================================================================
@@ -170,3 +169,4 @@
.float sv_entnum; // entity number sent from server
float vid_conwidth, vid_conheight;
float caps_team1, caps_team2;
+float configdb;
Modified: trunk/data/qcsrc/client/Main.qc
===================================================================
--- trunk/data/qcsrc/client/Main.qc 2008-07-19 19:54:01 UTC (rev 3847)
+++ trunk/data/qcsrc/client/Main.qc 2008-07-20 15:23:16 UTC (rev 3848)
@@ -21,6 +21,16 @@
float __engine_check;
#endif
+string config_get(string key, string defaultvalue)
+{
+ string s;
+ s = db_get(configdb, strcat("/s/", key));
+ if(s == "")
+ return defaultvalue;
+ else
+ return db_get(configdb, strcat("/v/", key));
+}
+
void CSQC_Init(void)
{
#ifdef USE_FTE
@@ -37,6 +47,9 @@
float i;
CSQC_CheckEngine();
+
+ configdb = db_create();
+
drawfont = 0;
menu_visible = FALSE;
menu_show = menu_show_error;
@@ -75,6 +88,7 @@
return 0;
#pragma TARGET fte
#endif
+ db_close(configdb);
buf_del(databuf);
}
@@ -393,6 +407,15 @@
return img;
}
+void Net_Config()
+{
+ string key, value;
+ key = ReadString();
+ value = ReadString();
+ db_put(configdb, strcat("/v/", key), value);
+ db_put(configdb, strcat("/s/", key), "1");
+}
+
// CSQC_Parse_TempEntity : Handles all temporary entity network data in the CSQC layer.
// You must ALWAYS first acquire the temporary ID, which is sent as a byte.
// Return value should be 1 if CSQC handled the temporary entity, otherwise return 0 to have the engine process the event.
@@ -431,7 +454,10 @@
Net_Mapvote();
bHandled = true;
break;
-
+ case TE_CSQC_CONFIG:
+ Net_Config();
+ bHandled = true;
+ break;
default:
// No special logic for this temporary entity; return 0 so the engine can handle it
bHandled = false;
Modified: trunk/data/qcsrc/client/csqc_builtins.qc
===================================================================
--- trunk/data/qcsrc/client/csqc_builtins.qc 2008-07-19 19:54:01 UTC (rev 3847)
+++ trunk/data/qcsrc/client/csqc_builtins.qc 2008-07-20 15:23:16 UTC (rev 3848)
@@ -20,7 +20,7 @@
string (string s) precache_sound = #19;
string (string s) precache_model = #20;
-void (string s) dprint = #25;
+//void (string s) dprint = #25;
string (float f) ftos = #26;
string (vector v) vtos = #27;
void () coredump = #28;
@@ -262,3 +262,9 @@
string(void) ReadPicture = #501;
string(string filename) whichpack = #503;
float(entity ent) num_for_edict = #512;
+float(string s, string separator1, ...) tokenizebyseparator = #479;
+string(string in) uri_unescape = #511;
+float(float caseinsensitive, string s, ...) crc16 = #494;
+string(string info, string key) infoget = #227;
+string(string info, string key, string value, ...) infoadd = #226;
+string(string in) uri_escape = #510;
Modified: trunk/data/qcsrc/client/main.qh
===================================================================
--- trunk/data/qcsrc/client/main.qh 2008-07-19 19:54:01 UTC (rev 3847)
+++ trunk/data/qcsrc/client/main.qh 2008-07-20 15:23:16 UTC (rev 3848)
@@ -86,3 +86,5 @@
float csqc_flags;
#define CSQC_FLAG_READPICTURE 1
+
+string config_get(string key, string defaultvalue);
Modified: trunk/data/qcsrc/client/mapvoting.qc
===================================================================
--- trunk/data/qcsrc/client/mapvoting.qc 2008-07-19 19:54:01 UTC (rev 3847)
+++ trunk/data/qcsrc/client/mapvoting.qc 2008-07-20 15:23:16 UTC (rev 3848)
@@ -217,6 +217,7 @@
if(mv_abstain)
mv_abstain = 1; // must be 1 for bool-true, makes stuff easier
mv_detail = ReadByte();
+
mv_ownvote = -1;
if(mv_num_maps <= 8)
@@ -237,7 +238,7 @@
pk3 = strzone(ReadString());
mv_maps[i] = map;
mv_pk3[i] = pk3;
- map = strzone(strcat("maps/", map));
+ map = strzone(strcat(config_get("mv_screenshot_dir", "maps"), "/", map));
mv_pics[i] = map;
mv_preview[i] = false;
Modified: trunk/data/qcsrc/client/pre.qh
===================================================================
--- trunk/data/qcsrc/client/pre.qh 2008-07-19 19:54:01 UTC (rev 3847)
+++ trunk/data/qcsrc/client/pre.qh 2008-07-20 15:23:16 UTC (rev 3848)
@@ -1,3 +1,5 @@
#ifdef USE_FTE
#pragma target FTE
#endif
+
+#define CSQC 1
Modified: trunk/data/qcsrc/client/progs.src
===================================================================
--- trunk/data/qcsrc/client/progs.src 2008-07-19 19:54:01 UTC (rev 3847)
+++ trunk/data/qcsrc/client/progs.src 2008-07-20 15:23:16 UTC (rev 3848)
@@ -4,8 +4,11 @@
Defs.qc
csqc_constants.qc
../common/constants.qh
+
csqc_builtins.qc
+../common/util.qh
+
main.qh
miscfunctions.qc
@@ -21,3 +24,5 @@
Main.qc
View.qc
+../common/util.qc
+../common/gamecommand.qc
Modified: trunk/data/qcsrc/common/constants.qh
===================================================================
--- trunk/data/qcsrc/common/constants.qh 2008-07-19 19:54:01 UTC (rev 3847)
+++ trunk/data/qcsrc/common/constants.qh 2008-07-20 15:23:16 UTC (rev 3848)
@@ -2,7 +2,8 @@
// Revision 1: additional statistics sent (flag caps, returns, deaths)
// Revision 2: Mapvote preview pictures
// Revision 3: optimized map vote protocol
-#define CSQC_REVISION 3
+// Revision 4: CSQC config var system
+#define CSQC_REVISION 4
// probably put these in common/
// so server/ and client/ can be synced better
@@ -173,6 +174,7 @@
const float TE_CSQC_DEATHS = 104;
const float TE_CSQC_PICTURE = 105;
const float TE_CSQC_MAPVOTE = 106;
+const float TE_CSQC_CONFIG = 107;
const float STAT_KH_KEYS = 32;
const float STAT_CTF_STATE = 33;
Modified: trunk/data/qcsrc/common/util.qc
===================================================================
--- trunk/data/qcsrc/common/util.qc 2008-07-19 19:54:01 UTC (rev 3847)
+++ trunk/data/qcsrc/common/util.qc 2008-07-20 15:23:16 UTC (rev 3848)
@@ -16,6 +16,7 @@
}
#ifndef MENUQC
+#ifndef CSQC
void wordwrap_buffer_sprint(string s)
{
wordwrap_buffer = strcat(wordwrap_buffer, s);
@@ -36,6 +37,7 @@
return;
}
#endif
+#endif
string unescape(string in)
{
Modified: trunk/data/qcsrc/common/util.qh
===================================================================
--- trunk/data/qcsrc/common/util.qh 2008-07-19 19:54:01 UTC (rev 3847)
+++ trunk/data/qcsrc/common/util.qh 2008-07-20 15:23:16 UTC (rev 3848)
@@ -13,8 +13,10 @@
// NOTE: s IS allowed to be a tempstring
string wordwrap(string s, float l);
#ifndef MENUQC
+#ifndef CSQC
void wordwrap_sprint(string s, float l);
#endif
+#endif
void wordwrap_cb(string s, float l, void(string) callback)
float GameCommand_Generic(string cmd);
Modified: trunk/data/qcsrc/server/cl_client.qc
===================================================================
--- trunk/data/qcsrc/server/cl_client.qc 2008-07-19 19:54:01 UTC (rev 3847)
+++ trunk/data/qcsrc/server/cl_client.qc 2008-07-20 15:23:16 UTC (rev 3848)
@@ -147,7 +147,7 @@
RandomSelection_Init();
for(spot = firstspot; spot; spot = spot.chain)
- RandomSelection_Add(spot, 0, pow(bound(lower, spot.frags, upper), exponent) * spot.cnt);
+ RandomSelection_Add(spot, 0, pow(bound(lower, spot.frags, upper), exponent) * spot.cnt, spot.frags >= lower);
return RandomSelection_chosen_ent;
}
@@ -2218,5 +2218,21 @@
//do nothing
}
+ /*
+ float i;
+ for(i = 0; i < 1000; ++i)
+ {
+ vector end;
+ end = self.origin + '0 0 1024' + 512 * randomvec();
+ tracebox(self.origin, self.mins, self.maxs, end, MOVE_NORMAL, self);
+ if(trace_fraction < 1)
+ if(!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
+ {
+ print("I HIT SOLID: ", vtos(self.origin), " -> ", vtos(end), "\n");
+ break;
+ }
+ }
+ */
+
Arena_Warmup();
}
Modified: trunk/data/qcsrc/server/g_world.qc
===================================================================
--- trunk/data/qcsrc/server/g_world.qc 2008-07-19 19:54:01 UTC (rev 3847)
+++ trunk/data/qcsrc/server/g_world.qc 2008-07-20 15:23:16 UTC (rev 3848)
@@ -1892,36 +1892,12 @@
NextLevel();
};
-float randsel_value;
-float randsel_priority;
-float randsel_count;
-void RandSel_Init()
-{
- randsel_value = -1;
- randsel_priority = -1;
- randsel_count = -1;
-}
-void RandSel_Add(float priority, float value)
-{
- if(priority > randsel_priority)
- {
- randsel_priority = priority;
- randsel_value = value;
- randsel_count = 1;
- }
- else if(priority == randsel_priority)
- {
- randsel_count += 1;
- if(ceil(random() * randsel_count) == 1)
- randsel_value = value;
- }
-}
-
float mapvote_nextthink;
float mapvote_initialized;
float mapvote_keeptwotime;
float mapvote_timeout;
string mapvote_message;
+string mapvote_screenshot_dir;
float mapvote_count;
float mapvote_count_real;
@@ -2058,6 +2034,11 @@
mapvote_keeptwotime = 0;
mapvote_message = "Choose a map and press its key!";
+ mapvote_screenshot_dir = cvar_string("g_maplist_votable_screenshot_dir");
+ if(mapvote_screenshot_dir == "")
+ mapvote_screenshot_dir = "maps";
+ mapvote_screenshot_dir = strzone(mapvote_screenshot_dir);
+
if(!cvar("g_maplist_textonly"))
MapVote_SendData(MSG_BROADCAST);
}
@@ -2069,7 +2050,7 @@
WriteByte(MSG_ONE, TE_CSQC_MAPVOTE);
WriteByte(MSG_ONE, MAPVOTE_NET_PIC);
WriteByte(MSG_ONE, id);
- WritePicture(MSG_ONE, strcat("maps/", mapvote_maps[id]), 1024);
+ WritePicture(MSG_ONE, strcat(mapvote_screenshot_dir, "/", mapvote_maps[id]), 1024);
}
float GameCommand_MapVote(string cmd)
@@ -2101,8 +2082,13 @@
void MapVote_SendData(float targ)
{
string mapfile;
- float i, o, c;
+ float i, o;
WriteByte(targ, SVC_TEMPENTITY);
+ WriteByte(targ, TE_CSQC_CONFIG);
+ WriteString(targ, "mv_screenshot_dir");
+ WriteString(targ, mapvote_screenshot_dir);
+
+ WriteByte(targ, SVC_TEMPENTITY);
WriteByte(targ, TE_CSQC_MAPVOTE);
WriteByte(targ, MAPVOTE_NET_INIT);
@@ -2117,8 +2103,12 @@
if(mapvote_maps[i] != "")
{
WriteString(targ, mapvote_maps[i]);
- mapfile = strcat("maps/", mapvote_maps[i], ".bsp");
- mapfile = whichpack(mapfile);
+ mapfile = strcat(mapvote_screenshot_dir, "/", mapvote_maps[i]);
+ mapfile = whichpack(strcat(mapfile, ".tga"));
+ if(mapfile == "")
+ mapfile = whichpack(strcat(mapfile, ".jpg"));
+ if(mapfile == "")
+ mapfile = whichpack(strcat(mapfile, ".png"));
for(o = strstr(mapfile, "/", 0)+1; o > 0; o = strstr(mapfile, "/", 0)+1)
mapfile = substring(mapfile, o, 999);
WriteString(targ, mapfile);
@@ -2143,7 +2133,6 @@
void MapVote_TellVote(float targ, float vote)
{
- float i;
WriteByte(targ, SVC_TEMPENTITY);
WriteByte(targ, TE_CSQC_MAPVOTE);
WriteByte(targ, MAPVOTE_NET_OWNVOTE);
@@ -2221,20 +2210,20 @@
if(mapvote_abstain)
mapvote_voters_real -= mapvote_votes[mapvote_count - 1];
- RandSel_Init();
+ RandomSelection_Init();
for(i = 0; i < mapvote_count_real; ++i) if(mapvote_maps[i] != "")
- RandSel_Add(mapvote_votes[i], i);
- firstPlace = randsel_value;
- firstPlaceVotes = randsel_priority;
+ RandomSelection_Add(world, i, 1, mapvote_votes[i]);
+ firstPlace = RandomSelection_chosen_float;
+ firstPlaceVotes = RandomSelection_best_priority;
//dprint("First place: ", ftos(firstPlace), "\n");
//dprint("First place votes: ", ftos(firstPlaceVotes), "\n");
- RandSel_Init();
+ RandomSelection_Init();
for(i = 0; i < mapvote_count_real; ++i) if(mapvote_maps[i] != "")
if(i != firstPlace)
- RandSel_Add(mapvote_votes[i], i);
- secondPlace = randsel_value;
- secondPlaceVotes = randsel_priority;
+ RandomSelection_Add(world, i, 1, mapvote_votes[i]);
+ secondPlace = RandomSelection_chosen_float;
+ secondPlaceVotes = RandomSelection_best_priority;
//dprint("Second place: ", ftos(secondPlace), "\n");
//dprint("Second place votes: ", ftos(secondPlaceVotes), "\n");
Modified: trunk/data/qcsrc/server/miscfunctions.qc
===================================================================
--- trunk/data/qcsrc/server/miscfunctions.qc 2008-07-19 19:54:01 UTC (rev 3847)
+++ trunk/data/qcsrc/server/miscfunctions.qc 2008-07-20 15:23:16 UTC (rev 3848)
@@ -3,6 +3,7 @@
string ColoredTeamName(float t);
float RandomSelection_totalweight;
+float RandomSelection_best_priority;
entity RandomSelection_chosen_ent;
float RandomSelection_chosen_float;
void RandomSelection_Init()
@@ -10,15 +11,26 @@
RandomSelection_totalweight = 0;
RandomSelection_chosen_ent = world;
RandomSelection_chosen_float = 0;
+ RandomSelection_best_priority = -1;
}
-void RandomSelection_Add(entity e, float f, float weight)
+void RandomSelection_Add(entity e, float f, float weight, float priority)
{
- RandomSelection_totalweight += weight;
- if(random() * RandomSelection_totalweight <= weight)
+ if(priority > RandomSelection_best_priority)
{
+ RandomSelection_best_priority = priority;
RandomSelection_chosen_ent = e;
RandomSelection_chosen_float = f;
+ RandomSelection_totalweight = weight;
}
+ else if(priority == RandomSelection_best_priority)
+ {
+ RandomSelection_totalweight += weight;
+ if(random() * RandomSelection_totalweight <= weight)
+ {
+ RandomSelection_chosen_ent = e;
+ RandomSelection_chosen_float = f;
+ }
+ }
}
float DistributeEvenly_amount;
Modified: trunk/data/qcsrc/server/sv_main.qc
===================================================================
--- trunk/data/qcsrc/server/sv_main.qc 2008-07-19 19:54:01 UTC (rev 3847)
+++ trunk/data/qcsrc/server/sv_main.qc 2008-07-20 15:23:16 UTC (rev 3848)
@@ -193,7 +193,7 @@
{
RandomSelection_Init();
for(self = world; (self = find(self, classname, "player")); )
- RandomSelection_Add(self, 0, 1);
+ RandomSelection_Add(self, 0, 1, 0);
self = RandomSelection_chosen_ent;
SelectSpawnPoint(0);
}
More information about the nexuiz-commits
mailing list