cvar_set(e.netname, e.message);
}
-void() menu_show_error =
+void menu_show_error()
{
drawstring('0 200 0', _("ERROR - MENU IS VISIBLE BUT NO MENU WAS DEFINED!"), '8 8 0', '1 0 0', 1, 0);
-};
+}
// CSQC_Init : Called every time the CSQC code is initialized (essentially at map load)
// Useful for precaching things
-void() menu_sub_null =
+void menu_sub_null()
{
-};
+}
#ifdef USE_FTE
float __engine_check;
#endif
+void precache_playermodel(string m)
+{
+ string f;
+
+ if(substring(m, -9,5) == "_lod1")
+ return;
+ if(substring(m, -9,5) == "_lod2")
+ return;
+ precache_model(m);
+ f = strcat(substring(m, 0, -5), "_lod1", substring(m, -4, -1));
+ if(fexists(f))
+ precache_model(f);
+ f = strcat(substring(m, 0, -5), "_lod2", substring(m, -4, -1));
+ if(fexists(f))
+ precache_model(f);
+
+ /*
+ float globhandle, i, n;
+ globhandle = search_begin(strcat(m, "_*.sounds"), TRUE, FALSE);
+ if (globhandle < 0)
+ return;
+ n = search_getsize(globhandle);
+ for (i = 0; i < n; ++i)
+ {
+ //print(search_getfilename(globhandle, i), "\n");
+ f = search_getfilename(globhandle, i);
+ PrecachePlayerSounds(f);
+ }
+ search_end(globhandle);
+ */
+}
+void precache_all_playermodels(string pattern)
+{
+ float globhandle, i, n;
+ string f;
+
+ globhandle = search_begin(pattern, TRUE, FALSE);
+ if (globhandle < 0)
+ return;
+ n = search_getsize(globhandle);
+ for (i = 0; i < n; ++i)
+ {
+ //print(search_getfilename(globhandle, i), "\n");
+ f = search_getfilename(globhandle, i);
+ precache_playermodel(f);
+ }
+ search_end(globhandle);
+}
+
string forcefog;
-string cl_announcer_prev;
void WaypointSprite_Load();
void CSQC_Init(void)
{
float i;
+#ifdef COMPAT_XON050_ENGINE
+ // old engine lacks implementation of player_localnum
+ player_localnum = player_localentnum - 1;
+#endif
+
binddb = db_create();
tempdb = db_create();
ClientProgsDB = db_load("client.db");
menu_action = menu_sub_null;
for(i = 0; i < 255; ++i)
- if(getplayerkey(i, "viewentity") == "")
+ if(getplayerkeyvalue(i, "viewentity") == "")
break;
maxclients = i;
- //ctf_temp_1 = "";
- // localcmd("alias order \"cmd order $*\""); enable if ctf-command thingy is used
- //registercmd("ctf_menu");
- registercmd("ons_map");
- registercmd("hud_configure");
- registercmd("hud_save");
- //registercmd("menu_action");
+ registercommand("hud_configure");
+ registercommand("hud_save");
+ //registercommand("menu_action");
- registercmd("+showscores");registercmd("-showscores");
- registercmd("+showaccuracy");registercmd("-showaccuracy");
+ registercommand("+showscores");registercommand("-showscores");
+ registercommand("+showaccuracy");registercommand("-showaccuracy");
#ifndef CAMERATEST
if(isdemo())
{
#endif
- registercmd("+forward");registercmd("-forward");
- registercmd("+back");registercmd("-back");
- registercmd("+moveup");registercmd("-moveup");
- registercmd("+movedown");registercmd("-movedown");
- registercmd("+moveright");registercmd("-moveright");
- registercmd("+moveleft");registercmd("-moveleft");
- registercmd("+roll_right");registercmd("-roll_right");
- registercmd("+roll_left");registercmd("-roll_left");
+ registercommand("+forward");registercommand("-forward");
+ registercommand("+back");registercommand("-back");
+ registercommand("+moveup");registercommand("-moveup");
+ registercommand("+movedown");registercommand("-movedown");
+ registercommand("+moveright");registercommand("-moveright");
+ registercommand("+moveleft");registercommand("-moveleft");
+ registercommand("+roll_right");registercommand("-roll_right");
+ registercommand("+roll_left");registercommand("-roll_left");
#ifndef CAMERATEST
}
#endif
registercvar("hud_usecsqc", "1");
- registercvar("scoreboard_columns", "default", CVAR_SAVE);
+ registercvar("scoreboard_columns", "default");
gametype = 0;
WaypointSprite_Load();
// precaches
+ precache_model("null");
precache_sound("misc/hit.wav");
precache_sound("misc/typehit.wav");
+ if (autocvar_cl_precacheplayermodels)
+ {
+ precache_all_playermodels("models/player/*.zym");
+ precache_all_playermodels("models/player/*.dpm");
+ precache_all_playermodels("models/player/*.md3");
+ precache_all_playermodels("models/player/*.psk");
+ precache_all_playermodels("models/player/*.iqm");
+ }
+
Projectile_Precache();
Hook_Precache();
GibSplash_Precache();
DamageInfo_Precache();
Vehicles_Precache();
turrets_precache();
-
- if(autocvar_cl_announcer != cl_announcer_prev) {
- Announcer_Precache();
- if(cl_announcer_prev)
- strunzone(cl_announcer_prev);
- cl_announcer_prev = strzone(autocvar_cl_announcer);
- }
+ Announcer_Precache();
Tuba_Precache();
-
- if(autocvar_cl_reticle_item_normal) precache_pic("gfx/reticle_normal");
- if(autocvar_cl_reticle_item_nex) precache_pic("gfx/reticle_nex");
-
+
+ if(autocvar_cl_reticle)
+ {
+ if(autocvar_cl_reticle_item_normal) { precache_pic("gfx/reticle_normal"); }
+ if(autocvar_cl_reticle_item_nex) { precache_pic("gfx/reticle_nex"); }
+ }
+
get_mi_min_max_texcoords(1); // try the CLEVER way first
minimapname = strcat("gfx/", mi_shortname, "_radar.tga");
shortmapname = mi_shortname;
case COLOR_TEAM4:
break;
default:
- if(GetTeam(Team, false) == NULL)
+ if(GetTeam(Team, false) == world)
{
print(sprintf(_("trying to switch to unsupported team %d\n"), Team));
Team = COLOR_SPECTATOR;
case 0:
break;
default:
- if(GetTeam(Team, false) == NULL)
+ if(GetTeam(Team, false) == world)
{
print(sprintf(_("trying to switch to unsupported team %d\n"), Team));
Team = COLOR_SPECTATOR;
postinit = true;
}
-// CSQC_ConsoleCommand : Used to parse commands in the console that have been registered with the "registercmd" function
+// CSQC_ConsoleCommand : Used to parse commands in the console that have been registered with the "registercommand" function
// Return value should be 1 if CSQC handled the command, otherwise return 0 to have the engine handle it.
float button_zoom;
void Cmd_HUD_SetFields(float);
{
float argc;
// Tokenize String
- //argc = tokenize(strMessage);
argc = tokenize_console(strMessage);
// Acquire Command
- local string strCmd;
+ string strCmd;
strCmd = argv(0);
if(strCmd == "hud_configure") { // config hud
{
vote_active = 0; // force the panel to disappear right as we have selected the value (to prevent it from fading out in the normal vote panel pos)
vote_prev = 0;
- cvar_set("cl_allow_uid2name", "1");
+ localcmd("setreport cl_allow_uid2name 1\n");
vote_change = -9999;
uid2name_dialog = 0;
}
{
vote_active = 0;
vote_prev = 0;
- cvar_set("cl_allow_uid2name", "0");
+ localcmd("setreport cl_allow_uid2name 0\n");
vote_change = -9999;
uid2name_dialog = 0;
}
// In the case of mouse input, nPrimary is xdelta, nSecondary is ydelta.
float CSQC_InputEvent(float bInputType, float nPrimary, float nSecondary)
{
- local float bSkipKey;
+ float bSkipKey;
bSkipKey = false;
if (HUD_Panel_InputEvent(bInputType, nPrimary, nSecondary))
if(f & 2)
{
newspectatee_status = ReadByte();
- if(newspectatee_status == player_localentnum)
+ if(newspectatee_status == player_localnum + 1)
newspectatee_status = -1; // observing
}
else
prev_health = -1;
}
spectatee_status = newspectatee_status;
+
+ // non-COMPAT_XON050_ENGINE: we could get rid of spectatee_status, and derive it from player_localentnum and player_localnum
}
void Ent_Nagger()
void Ent_RadarLink();
void Ent_Init();
void Ent_ScoresInfo();
-void(float bIsNewEntity) CSQC_Ent_Update =
+void CSQC_Ent_Update(float bIsNewEntity)
{
float t;
float savetime;
#ifdef DP_CSQC_ENTITY_REMOVE_IS_B0RKED
if(self.enttype)
- if(t != self.enttype)
+ {
+ if(t != self.enttype || bIsNewEntity)
{
//print(_("A CSQC entity changed its type!\n"));
- print(sprintf(_("A CSQC entity changed its type! (edict: %d, classname: %s)\n"), num_for_edict(self), self.classname));
+ print(sprintf(_("A CSQC entity changed its type! (edict: %d, server: %d, type: %d -> %d)\n"), num_for_edict(self), self.entnum, self.enttype, t));
Ent_Remove();
bIsNewEntity = 1;
}
+ }
+ else
+ {
+ if(!bIsNewEntity)
+ {
+ print(sprintf(_("A CSQC entity appeared out of nowhere! (edict: %d, server: %d, type: %d)\n"), num_for_edict(self), self.entnum, t));
+ bIsNewEntity = 1;
+ }
+ }
#endif
self.enttype = t;
switch(t)
case ENT_CLIENT_ACCURACY: Ent_ReadAccuracy(); break;
case ENT_CLIENT_AUXILIARYXHAIR: Net_AuXair2(bIsNewEntity); break;
case ENT_CLIENT_TURRET: ent_turret(); break;
+ case ENT_CLIENT_MODEL: CSQCModel_Read(); break;
default:
//error(strcat(_("unknown entity type in CSQC_Ent_Update: %d\n"), self.enttype));
error(sprintf(_("Unknown entity type in CSQC_Ent_Update (enttype: %d, edict: %d, classname: %s)\n"), self.enttype, num_for_edict(self), self.classname));
}
time = savetime;
-};
+}
// Destructor, but does NOT deallocate the entity by calling remove(). Also
// used when an entity changes its type. For an entity that someone interacts
// with others, make sure it can no longer do so.
print(ColorTranslateRGB(strMessage));
}
-// CSQC_Parse_CenterPrint : Provides the centerprint string in the first parameter that the server provided.
+// CSQC_Parse_CenterPrint : Provides the centerprint_hud string in the first parameter that the server provided.
void CSQC_Parse_CenterPrint(string strMessage)
{
- centerprint(strMessage);
+ centerprint_hud(strMessage);
}
string notranslate_fogcmd1 = "\nfog ";
nex_scope = !ReadByte();
rifle_scope = !ReadByte();
- serverflags = ReadByte();
-
minelayer_maxmines = ReadByte();
hagar_maxrockets = ReadByte();
strunzone(grecordholder[pos-1]);
grecordholder[pos-1] = strzone(ReadString());
grecordtime[pos-1] = ReadInt24_t();
- if(grecordholder[pos-1] == GetPlayerName(player_localentnum -1))
+ if(grecordholder[pos-1] == GetPlayerName(player_localnum))
race_myrank = pos;
break;
case RACE_NET_SERVER_STATUS:
// Return value should be 1 if CSQC handled the temporary entity, otherwise return 0 to have the engine process the event.
float CSQC_Parse_TempEntity()
{
- local float bHandled;
+ float bHandled;
bHandled = true;
// Acquire TE ID
- local float nTEID;
+ float nTEID;
nTEID = ReadByte();
// NOTE: Could just do return instead of break...
bHandled = true;
break;
case TE_CSQC_ANNOUNCE:
- announce_snd = strzone(ReadString());
+ Announcer_Play(ReadString());
bHandled = true;
break;
case TE_CSQC_KILLNOTIFY:
Net_WeaponComplain();
bHandled = true;
break;
- case TE_CSQC_VEHICLESETUP:
- Net_VehicleSetup();
- bHandled = true;
- break;
+ case TE_CSQC_VEHICLESETUP:
+ Net_VehicleSetup();
+ bHandled = true;
+ break;
default:
// No special logic for this temporary entity; return 0 so the engine can handle it
bHandled = false;
keys = db_get(binddb, command);
if (!keys)
{
- n = tokenize(findkeysforcommand(command)); // uses '...' strings
+ n = tokenize(findkeysforcommand(command, 0)); // uses '...' strings
for(j = 0; j < n; ++j)
{
k = stof(argv(j));