From 6eb2ea75861bdd2cde4118bb3c6ec33026315564 Mon Sep 17 00:00:00 2001 From: Alison Watson Date: Sun, 8 Dec 2019 15:35:56 -0500 Subject: [PATCH] misc cleanup, computed goto for interpreter when available --- CMakeLists.txt | 18 ++ source/cl_parse.c | 8 +- source/cvar.c | 4 +- source/gl_draw.c | 5 +- source/gl_model.c | 10 +- source/gl_rmain.c | 10 +- source/gl_rmisc.c | 4 +- source/gl_screen.c | 16 +- source/gl_warp.c | 2 +- source/host.c | 12 +- source/host_cmd.c | 260 +++++++++++----------- source/menu.c | 6 +- source/net_dgrm.c | 4 +- source/pr_cmds.c | 364 +++++++++++++++---------------- source/pr_edict.c | 82 +++---- source/pr_edict.h | 34 +-- source/pr_exec.c | 344 +++++++++++------------------ source/pr_global.h | 24 +-- source/pr_load.c | 42 ++-- source/pr_ops.h | 160 +++++++------- source/pr_string.c | 10 +- source/protocol.h | 2 +- source/r_brush.c | 5 +- source/sbar.c | 20 +- source/sdl/gl_vidsdl.c | 10 +- source/server.h | 2 +- source/snd_dma.c | 2 +- source/sv_main.c | 248 ++++++++++----------- source/sv_move.c | 80 +++---- source/sv_phys.c | 440 +++++++++++++++++++------------------- source/sv_user.c | 76 +++---- source/unix/net_udp.c | 4 +- source/wad.c | 2 +- source/windows/net_wins.c | 6 +- source/windows/net_wipx.c | 8 +- source/world.c | 132 ++++++------ source/world.h | 2 +- source/zone.c | 10 +- 38 files changed, 1209 insertions(+), 1259 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7052ea3..3836583 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,8 @@ cmake_policy(SET CMP0071 NEW) project(agw-quake C) +include(CheckCSourceCompiles) + find_package(OpenGL REQUIRED) find_package(PkgConfig REQUIRED) @@ -19,6 +21,18 @@ pkg_check_modules(Opus IMPORTED_TARGET opus>=1.3.1 ogg>=1.3.4) pkg_check_modules(MikMod IMPORTED_TARGET libmikmod>=3.3.11) +check_c_source_compiles( + "int main(int argc, char *argv[]) { + static void *const ar[] = {&&c0, &&c1, &&c2, &&c3}; + goto *ar[argc]; + c0: return 1; + c1: return 2; + c2: return 3; + c3: return 4; + return 0; + }" + HAVE_COMPUTED_GOTO) + set(srcs source/anorm_dots.h source/anorms.h @@ -199,6 +213,10 @@ agw_checked_library(USE_CODEC_VORBIS Vorbis) agw_checked_library(USE_CODEC_OPUS Opus) agw_checked_library(USE_CODEC_MikMod MikMod) +if(HAVE_COMPUTED_GOTO) + target_compile_definitions(quake PUBLIC -DHAVE_COMPUTED_GOTO=1) +endif() + target_compile_options(quake PUBLIC $<$: -Wall -Wextra -Werror -Wno-missing-field-initializers> diff --git a/source/cl_parse.c b/source/cl_parse.c index 2f20f70..d46b368 100644 --- a/source/cl_parse.c +++ b/source/cl_parse.c @@ -177,7 +177,7 @@ void CL_ParseStartSoundPacket(void) //johnfitz if(ent > cl_max_edicts) //johnfitz -- no more MAX_EDICTS - Host_Error("CL_ParseStartSoundPacket: ent = %" PRIi32 "", ent); + Host_Error("CL_ParseStartSoundPacket: ent = %" PRIi32, ent); for(i = 0; i < 3; i++) pos[i] = MSG_ReadCoord(cl.protocolflags); @@ -280,7 +280,7 @@ void CL_ParseServerInfo(void) if(i != PROTOCOL_NETQUAKE && i != PROTOCOL_FITZQUAKE && i != PROTOCOL_RMQ) { Con_Printf("\n"); //because there's no newline after serverinfo print - Host_Error("Server returned version %" PRIi32 ", not %" PRIi32 " or %" PRIi32 " or %" PRIi32 "", i, PROTOCOL_NETQUAKE, PROTOCOL_FITZQUAKE, PROTOCOL_RMQ); + Host_Error("Server returned version %" PRIi32 ", not %" PRIi32 " or %" PRIi32 " or %" PRIi32, i, PROTOCOL_NETQUAKE, PROTOCOL_FITZQUAKE, PROTOCOL_RMQ); } cl.protocol = i; //johnfitz @@ -1009,7 +1009,7 @@ void CL_ParseServerMessage(void) i = MSG_ReadLong(); //johnfitz -- support multiple protocols if(i != PROTOCOL_NETQUAKE && i != PROTOCOL_FITZQUAKE && i != PROTOCOL_RMQ) - Host_Error("Server returned version %" PRIi32 ", not %" PRIi32 " or %" PRIi32 " or %" PRIi32 "", i, PROTOCOL_NETQUAKE, PROTOCOL_FITZQUAKE, PROTOCOL_RMQ); + Host_Error("Server returned version %" PRIi32 ", not %" PRIi32 " or %" PRIi32 " or %" PRIi32, i, PROTOCOL_NETQUAKE, PROTOCOL_FITZQUAKE, PROTOCOL_RMQ); cl.protocol = i; //johnfitz break; @@ -1137,7 +1137,7 @@ void CL_ParseServerMessage(void) case svc_signonnum: i = MSG_ReadByte(); if(i <= cls.signon) - Host_Error("Received signon %" PRIi32 " when at %" PRIi32 "", i, cls.signon); + Host_Error("Received signon %" PRIi32 " when at %" PRIi32, i, cls.signon); cls.signon = i; //johnfitz -- if signonnum==2, signon packet has been fully parsed, so check for excessive static ents and efrags if(i == 2) diff --git a/source/cvar.c b/source/cvar.c index 93cde2f..e5eaa0d 100644 --- a/source/cvar.c +++ b/source/cvar.c @@ -433,7 +433,7 @@ void Cvar_SetValueQuick(cvar_t *var, const float value) char val[32], *ptr = val; if(value == (float)((int32_t)value)) - q_snprintf(val, sizeof(val), "%" PRIi32 "", (int32_t)value); + q_snprintf(val, sizeof(val), "%" PRIi32, (int32_t)value); else { q_snprintf(val, sizeof(val), "%f", value); @@ -477,7 +477,7 @@ void Cvar_SetValue(const char *var_name, const float value) char val[32], *ptr = val; if(value == (float)((int32_t)value)) - q_snprintf(val, sizeof(val), "%" PRIi32 "", (int32_t)value); + q_snprintf(val, sizeof(val), "%" PRIi32, (int32_t)value); else { q_snprintf(val, sizeof(val), "%f", value); diff --git a/source/gl_draw.c b/source/gl_draw.c index 4226f6d..710d87f 100644 --- a/source/gl_draw.c +++ b/source/gl_draw.c @@ -201,9 +201,8 @@ void Scrap_Upload(void) for(i = 0; i < MAX_SCRAPS; i++) { - sprintf(name, "scrap%" PRIi32 "", i); - scrap_textures[i] = TexMgr_LoadImage(NULL, name, BLOCK_WIDTH, BLOCK_HEIGHT, SRC_INDEXED, scrap_texels[i], - "", (src_offset_t)scrap_texels[i], TEXPREF_ALPHA | TEXPREF_OVERWRITE | TEXPREF_NOPICMIP); + sprintf(name, "scrap%" PRIi32, i); + scrap_textures[i] = TexMgr_LoadImage(NULL, name, BLOCK_WIDTH, BLOCK_HEIGHT, SRC_INDEXED, scrap_texels[i], "", (src_offset_t)scrap_texels[i], TEXPREF_ALPHA | TEXPREF_OVERWRITE | TEXPREF_NOPICMIP); } scrap_dirty = false; diff --git a/source/gl_model.c b/source/gl_model.c index 1afd12b..f1f6691 100644 --- a/source/gl_model.c +++ b/source/gl_model.c @@ -2093,7 +2093,7 @@ void Mod_LoadBrushModel(qmodel_t *mod, void *buffer) // duplicate the basic information char name[10]; - sprintf(name, "*%" PRIi32 "", i + 1); + sprintf(name, "*%" PRIi32, i + 1); loadmodel = Mod_FindName(name); *loadmodel = *mod; strcpy(loadmodel->name, name); @@ -2321,7 +2321,7 @@ void *Mod_LoadAllSkins(int32_t numskins, daliasskintype_t *pskintype) memcpy(texels, (byte *)(pskintype + 1), size); //johnfitz -- rewritten - q_snprintf(name, sizeof(name), "%s:frame%" PRIi32 "", loadmodel->name, i); + q_snprintf(name, sizeof(name), "%s:frame%" PRIi32, loadmodel->name, i); offset = (src_offset_t)(pskintype + 1) - (src_offset_t)mod_base; if(Mod_CheckFullbrights((byte *)(pskintype + 1), size)) { @@ -2365,7 +2365,7 @@ void *Mod_LoadAllSkins(int32_t numskins, daliasskintype_t *pskintype) } //johnfitz -- rewritten - q_snprintf(name, sizeof(name), "%s:frame%" PRIi32 "_%" PRIi32 "", loadmodel->name, i, j); + q_snprintf(name, sizeof(name), "%s:frame%" PRIi32 "_%" PRIi32, loadmodel->name, i, j); offset = (src_offset_t)(pskintype) - (src_offset_t)mod_base; //johnfitz if(Mod_CheckFullbrights((byte *)(pskintype), size)) { @@ -2555,7 +2555,7 @@ void Mod_LoadAliasModel(qmodel_t *mod, void *buffer) pheader->skinheight = LittleLong(pinmodel->skinheight); if(pheader->skinheight > MAX_LBM_HEIGHT) - Sys_Error("model %s has a skin taller than %" PRIi32 "", mod->name, + Sys_Error("model %s has a skin taller than %" PRIi32, mod->name, MAX_LBM_HEIGHT); pheader->numverts = LittleLong(pinmodel->numverts); @@ -2704,7 +2704,7 @@ void * Mod_LoadSpriteFrame(void * pin, mspriteframe_t **ppframe, int32_t framenu pspriteframe->tmax = (float)height / (float)TexMgr_PadConditional(height); //johnfitz - q_snprintf(name, sizeof(name), "%s:frame%" PRIi32 "", loadmodel->name, framenum); + q_snprintf(name, sizeof(name), "%s:frame%" PRIi32, loadmodel->name, framenum); offset = (src_offset_t)(pinframe + 1) - (src_offset_t)mod_base; //johnfitz pspriteframe->gltexture = TexMgr_LoadImage(loadmodel, name, width, height, SRC_INDEXED, diff --git a/source/gl_rmain.c b/source/gl_rmain.c index 7707377..4f9192f 100644 --- a/source/gl_rmain.c +++ b/source/gl_rmain.c @@ -744,7 +744,7 @@ void R_ShowBoundingBoxes(void) glDisable(GL_CULL_FACE); glColor3f(1, 1, 1); - for(i = 0, ed = NEXT_EDICT(sv.edicts) ; i < sv.num_edicts ; i++, ed = NEXT_EDICT(ed)) + for(i = 0, ed = NextEdict(sv.edicts) ; i < sv.num_edicts ; i++, ed = NextEdict(ed)) { if(ed == sv_player) continue; //don't draw player's own bbox @@ -753,16 +753,16 @@ void R_ShowBoundingBoxes(void) // if (!SV_VisibleToClient (sv_player, ed, sv.worldmodel)) // continue; //don't draw if not in pvs - if(ED_VECTOR(ed, ED_mins)[0] == ED_VECTOR(ed, ED_maxs)[0] && ED_VECTOR(ed, ED_mins)[1] == ED_VECTOR(ed, ED_maxs)[1] && ED_VECTOR(ed, ED_mins)[2] == ED_VECTOR(ed, ED_maxs)[2]) + if(ED_Vector(ed, ED_mins)[0] == ED_Vector(ed, ED_maxs)[0] && ED_Vector(ed, ED_mins)[1] == ED_Vector(ed, ED_maxs)[1] && ED_Vector(ed, ED_mins)[2] == ED_Vector(ed, ED_maxs)[2]) { //point entity - R_EmitWirePoint(ED_VECTOR(ed, ED_origin)); + R_EmitWirePoint(ED_Vector(ed, ED_origin)); } else { //box entity - VectorAdd(ED_VECTOR(ed, ED_mins), ED_VECTOR(ed, ED_origin), mins); - VectorAdd(ED_VECTOR(ed, ED_maxs), ED_VECTOR(ed, ED_origin), maxs); + VectorAdd(ED_Vector(ed, ED_mins), ED_Vector(ed, ED_origin), mins); + VectorAdd(ED_Vector(ed, ED_maxs), ED_Vector(ed, ED_origin), maxs); R_EmitWireBox(mins, maxs); } } diff --git a/source/gl_rmisc.c b/source/gl_rmisc.c index 3ac1155..3da9d52 100644 --- a/source/gl_rmisc.c +++ b/source/gl_rmisc.c @@ -305,7 +305,7 @@ void R_TranslateNewPlayerSkin(int32_t playernum) pixels = (byte *)paliashdr + paliashdr->texels[skinnum]; // This is not a persistent place! //upload new image - q_snprintf(name, sizeof(name), "player_%" PRIi32 "", playernum); + q_snprintf(name, sizeof(name), "player_%" PRIi32, playernum); playertextures[playernum] = TexMgr_LoadImage(currententity->model, name, paliashdr->skinwidth, paliashdr->skinheight, SRC_INDEXED, pixels, paliashdr->gltextures[skinnum][0]->source_file, paliashdr->gltextures[skinnum][0]->source_offset, TEXPREF_PAD | TEXPREF_OVERWRITE); @@ -625,7 +625,7 @@ void GL_BindBuffer(GLenum target, GLuint buffer) cache = ¤t_element_array_buffer; break; default: - Host_Error("GL_BindBuffer: unsupported target %" PRIi32 "", (int32_t)target); + Host_Error("GL_BindBuffer: unsupported target %" PRIi32, (int32_t)target); return; } diff --git a/source/gl_screen.c b/source/gl_screen.c index 034f7ec..b0cabbc 100644 --- a/source/gl_screen.c +++ b/source/gl_screen.c @@ -496,7 +496,7 @@ void SCR_DrawClock(void) minutes = cl.time / 60; seconds = ((int32_t)cl.time) % 60; - sprintf(str, "%" PRIi32 ":%" PRIi32 "%" PRIi32 "", minutes, seconds / 10, seconds % 10); + sprintf(str, "%" PRIi32 ":%" PRIi32 "%" PRIi32, minutes, seconds / 10, seconds % 10); } else return; @@ -532,25 +532,25 @@ void SCR_DrawDevStats(void) sprintf(str, "---------+---------"); Draw_String(x, (y++) * 8 - x, str); - sprintf(str, "Edicts |%4" PRIi32 " %4" PRIi32 "", dev_stats.edicts, dev_peakstats.edicts); + sprintf(str, "Edicts |%4" PRIi32 " %4" PRIi32, dev_stats.edicts, dev_peakstats.edicts); Draw_String(x, (y++) * 8 - x, str); - sprintf(str, "Packet |%4" PRIi32 " %4" PRIi32 "", dev_stats.packetsize, dev_peakstats.packetsize); + sprintf(str, "Packet |%4" PRIi32 " %4" PRIi32, dev_stats.packetsize, dev_peakstats.packetsize); Draw_String(x, (y++) * 8 - x, str); - sprintf(str, "Visedicts|%4" PRIi32 " %4" PRIi32 "", dev_stats.visedicts, dev_peakstats.visedicts); + sprintf(str, "Visedicts|%4" PRIi32 " %4" PRIi32, dev_stats.visedicts, dev_peakstats.visedicts); Draw_String(x, (y++) * 8 - x, str); - sprintf(str, "Efrags |%4" PRIi32 " %4" PRIi32 "", dev_stats.efrags, dev_peakstats.efrags); + sprintf(str, "Efrags |%4" PRIi32 " %4" PRIi32, dev_stats.efrags, dev_peakstats.efrags); Draw_String(x, (y++) * 8 - x, str); - sprintf(str, "Dlights |%4" PRIi32 " %4" PRIi32 "", dev_stats.dlights, dev_peakstats.dlights); + sprintf(str, "Dlights |%4" PRIi32 " %4" PRIi32, dev_stats.dlights, dev_peakstats.dlights); Draw_String(x, (y++) * 8 - x, str); - sprintf(str, "Beams |%4" PRIi32 " %4" PRIi32 "", dev_stats.beams, dev_peakstats.beams); + sprintf(str, "Beams |%4" PRIi32 " %4" PRIi32, dev_stats.beams, dev_peakstats.beams); Draw_String(x, (y++) * 8 - x, str); - sprintf(str, "Tempents |%4" PRIi32 " %4" PRIi32 "", dev_stats.tempents, dev_peakstats.tempents); + sprintf(str, "Tempents |%4" PRIi32 " %4" PRIi32, dev_stats.tempents, dev_peakstats.tempents); Draw_String(x, (y++) * 8 - x, str); } diff --git a/source/gl_warp.c b/source/gl_warp.c index f0b31f4..94b4c37 100644 --- a/source/gl_warp.c +++ b/source/gl_warp.c @@ -83,7 +83,7 @@ void SubdividePolygon(int32_t numverts, float *verts) float s, t; if(numverts > 60) - Sys_Error("numverts = %" PRIi32 "", numverts); + Sys_Error("numverts = %" PRIi32, numverts); BoundPoly(numverts, verts, mins, maxs); diff --git a/source/host.c b/source/host.c index 73f4362..5260b2d 100644 --- a/source/host.c +++ b/source/host.c @@ -420,10 +420,10 @@ void SV_DropClient(bool crash) { // call the prog function for removing a client // this will set the body to a dead frame, among other things - saveSelf = G_PEDICT(GBL_self); - G_PEDICT(GBL_self) = EDICT_TO_PROG(host_client->edict); - PR_ExecuteProgram(G_FUNC(GBL_ClientDisconnect)); - G_PEDICT(GBL_self) = saveSelf; + saveSelf = G_PEdict(GBL_self); + G_PEdict(GBL_self) = EdictProg(host_client->edict); + PR_ExecuteProgram(G_Func(GBL_ClientDisconnect)); + G_PEdict(GBL_self) = saveSelf; } Sys_Printf("Client %s removed\n", host_client->name); @@ -623,7 +623,7 @@ void Host_ServerFrame(void) edict_t *ent; //johnfitz // run the world state - G_FLOAT(GBL_frametime) = host_frametime; + G_Float(GBL_frametime) = host_frametime; // set the time and clear the general datagram SV_ClearDatagram(); @@ -644,7 +644,7 @@ void Host_ServerFrame(void) { for(i = 0, active = 0; i < sv.num_edicts; i++) { - ent = EDICT_NUM(i); + ent = EdictNum(i); if(!ent->free) active++; } diff --git a/source/host_cmd.c b/source/host_cmd.c index 9215412..2e16534 100644 --- a/source/host_cmd.c +++ b/source/host_cmd.c @@ -470,7 +470,7 @@ void Host_Status_f(void) } else hours = 0; - print_fn("#%-2" PRIu32 " %-16.16s %3" PRIi32 " %2" PRIi32 ":%02" PRIi32 ":%02" PRIi32 "n", j + 1, client->name, (int32_t)ED_FLOAT(client->edict, ED_frags), hours, minutes, seconds); + print_fn("#%-2" PRIu32 " %-16.16s %3" PRIi32 " %2" PRIi32 ":%02" PRIi32 ":%02" PRIi32 "n", j + 1, client->name, (int32_t)ED_Float(client->edict, ED_frags), hours, minutes, seconds); print_fn(" %s\n", NET_QSocketGetAddressString(client->netconnection)); } } @@ -490,15 +490,15 @@ void Host_God_f(void) return; } - if(G_FLOAT(GBL_deathmatch)) + if(G_Float(GBL_deathmatch)) return; //johnfitz -- allow user to explicitly set god mode to on or off switch(Cmd_Argc()) { case 1: - ED_FLOAT(sv_player, ED_flags) = (int32_t)ED_FLOAT(sv_player, ED_flags) ^ FL_GODMODE; - if(!((int32_t)ED_FLOAT(sv_player, ED_flags) & FL_GODMODE)) + ED_Float(sv_player, ED_flags) = (int32_t)ED_Float(sv_player, ED_flags) ^ FL_GODMODE; + if(!((int32_t)ED_Float(sv_player, ED_flags) & FL_GODMODE)) SV_ClientPrintf("godmode OFF\n"); else SV_ClientPrintf("godmode ON\n"); @@ -506,12 +506,12 @@ void Host_God_f(void) case 2: if(atof(Cmd_Argv(1))) { - ED_FLOAT(sv_player, ED_flags) = (int32_t)ED_FLOAT(sv_player, ED_flags) | FL_GODMODE; + ED_Float(sv_player, ED_flags) = (int32_t)ED_Float(sv_player, ED_flags) | FL_GODMODE; SV_ClientPrintf("godmode ON\n"); } else { - ED_FLOAT(sv_player, ED_flags) = (int32_t)ED_FLOAT(sv_player, ED_flags) & ~FL_GODMODE; + ED_Float(sv_player, ED_flags) = (int32_t)ED_Float(sv_player, ED_flags) & ~FL_GODMODE; SV_ClientPrintf("godmode OFF\n"); } break; @@ -535,15 +535,15 @@ void Host_Notarget_f(void) return; } - if(G_FLOAT(GBL_deathmatch)) + if(G_Float(GBL_deathmatch)) return; //johnfitz -- allow user to explicitly set notarget to on or off switch(Cmd_Argc()) { case 1: - ED_FLOAT(sv_player, ED_flags) = (int32_t)ED_FLOAT(sv_player, ED_flags) ^ FL_NOTARGET; - if(!((int32_t)ED_FLOAT(sv_player, ED_flags) & FL_NOTARGET)) + ED_Float(sv_player, ED_flags) = (int32_t)ED_Float(sv_player, ED_flags) ^ FL_NOTARGET; + if(!((int32_t)ED_Float(sv_player, ED_flags) & FL_NOTARGET)) SV_ClientPrintf("notarget OFF\n"); else SV_ClientPrintf("notarget ON\n"); @@ -551,12 +551,12 @@ void Host_Notarget_f(void) case 2: if(atof(Cmd_Argv(1))) { - ED_FLOAT(sv_player, ED_flags) = (int32_t)ED_FLOAT(sv_player, ED_flags) | FL_NOTARGET; + ED_Float(sv_player, ED_flags) = (int32_t)ED_Float(sv_player, ED_flags) | FL_NOTARGET; SV_ClientPrintf("notarget ON\n"); } else { - ED_FLOAT(sv_player, ED_flags) = (int32_t)ED_FLOAT(sv_player, ED_flags) & ~FL_NOTARGET; + ED_Float(sv_player, ED_flags) = (int32_t)ED_Float(sv_player, ED_flags) & ~FL_NOTARGET; SV_ClientPrintf("notarget OFF\n"); } break; @@ -582,23 +582,23 @@ void Host_Noclip_f(void) return; } - if(G_FLOAT(GBL_deathmatch)) + if(G_Float(GBL_deathmatch)) return; //johnfitz -- allow user to explicitly set noclip to on or off switch(Cmd_Argc()) { case 1: - if(ED_FLOAT(sv_player, ED_movetype) != MOVETYPE_NOCLIP) + if(ED_Float(sv_player, ED_movetype) != MOVETYPE_NOCLIP) { noclip_anglehack = true; - ED_FLOAT(sv_player, ED_movetype) = MOVETYPE_NOCLIP; + ED_Float(sv_player, ED_movetype) = MOVETYPE_NOCLIP; SV_ClientPrintf("noclip ON\n"); } else { noclip_anglehack = false; - ED_FLOAT(sv_player, ED_movetype) = MOVETYPE_WALK; + ED_Float(sv_player, ED_movetype) = MOVETYPE_WALK; SV_ClientPrintf("noclip OFF\n"); } break; @@ -606,13 +606,13 @@ void Host_Noclip_f(void) if(atof(Cmd_Argv(1))) { noclip_anglehack = true; - ED_FLOAT(sv_player, ED_movetype) = MOVETYPE_NOCLIP; + ED_Float(sv_player, ED_movetype) = MOVETYPE_NOCLIP; SV_ClientPrintf("noclip ON\n"); } else { noclip_anglehack = false; - ED_FLOAT(sv_player, ED_movetype) = MOVETYPE_WALK; + ED_Float(sv_player, ED_movetype) = MOVETYPE_WALK; SV_ClientPrintf("noclip OFF\n"); } break; @@ -638,7 +638,7 @@ void Host_SetPos_f(void) return; } - if(G_FLOAT(GBL_deathmatch)) + if(G_Float(GBL_deathmatch)) return; if(Cmd_Argc() != 7 && Cmd_Argc() != 4) @@ -648,37 +648,37 @@ void Host_SetPos_f(void) SV_ClientPrintf(" setpos \n"); SV_ClientPrintf("current values:\n"); SV_ClientPrintf(" %" PRIi32 " %" PRIi32 " %" PRIi32 " %" PRIi32 " %" PRIi32 " %" PRIi32 "\n", - (int32_t)ED_VECTOR(sv_player, ED_origin)[0], - (int32_t)ED_VECTOR(sv_player, ED_origin)[1], - (int32_t)ED_VECTOR(sv_player, ED_origin)[2], - (int32_t)ED_VECTOR(sv_player, ED_v_angle)[0], - (int32_t)ED_VECTOR(sv_player, ED_v_angle)[1], - (int32_t)ED_VECTOR(sv_player, ED_v_angle)[2]); + (int32_t)ED_Vector(sv_player, ED_origin)[0], + (int32_t)ED_Vector(sv_player, ED_origin)[1], + (int32_t)ED_Vector(sv_player, ED_origin)[2], + (int32_t)ED_Vector(sv_player, ED_v_angle)[0], + (int32_t)ED_Vector(sv_player, ED_v_angle)[1], + (int32_t)ED_Vector(sv_player, ED_v_angle)[2]); return; } - if(ED_FLOAT(sv_player, ED_movetype) != MOVETYPE_NOCLIP) + if(ED_Float(sv_player, ED_movetype) != MOVETYPE_NOCLIP) { noclip_anglehack = true; - ED_FLOAT(sv_player, ED_movetype) = MOVETYPE_NOCLIP; + ED_Float(sv_player, ED_movetype) = MOVETYPE_NOCLIP; SV_ClientPrintf("noclip ON\n"); } //make sure they're not going to whizz away from it - ED_VECTOR(sv_player, ED_velocity)[0] = 0; - ED_VECTOR(sv_player, ED_velocity)[1] = 0; - ED_VECTOR(sv_player, ED_velocity)[2] = 0; + ED_Vector(sv_player, ED_velocity)[0] = 0; + ED_Vector(sv_player, ED_velocity)[1] = 0; + ED_Vector(sv_player, ED_velocity)[2] = 0; - ED_VECTOR(sv_player, ED_origin)[0] = atof(Cmd_Argv(1)); - ED_VECTOR(sv_player, ED_origin)[1] = atof(Cmd_Argv(2)); - ED_VECTOR(sv_player, ED_origin)[2] = atof(Cmd_Argv(3)); + ED_Vector(sv_player, ED_origin)[0] = atof(Cmd_Argv(1)); + ED_Vector(sv_player, ED_origin)[1] = atof(Cmd_Argv(2)); + ED_Vector(sv_player, ED_origin)[2] = atof(Cmd_Argv(3)); if(Cmd_Argc() == 7) { - ED_VECTOR(sv_player, ED_angles)[0] = atof(Cmd_Argv(4)); - ED_VECTOR(sv_player, ED_angles)[1] = atof(Cmd_Argv(5)); - ED_VECTOR(sv_player, ED_angles)[2] = atof(Cmd_Argv(6)); - ED_FLOAT(sv_player, ED_fixangle) = 1; + ED_Vector(sv_player, ED_angles)[0] = atof(Cmd_Argv(4)); + ED_Vector(sv_player, ED_angles)[1] = atof(Cmd_Argv(5)); + ED_Vector(sv_player, ED_angles)[2] = atof(Cmd_Argv(6)); + ED_Float(sv_player, ED_fixangle) = 1; } SV_LinkEdict(sv_player, false); @@ -699,33 +699,33 @@ void Host_Fly_f(void) return; } - if(G_FLOAT(GBL_deathmatch)) + if(G_Float(GBL_deathmatch)) return; //johnfitz -- allow user to explicitly set noclip to on or off switch(Cmd_Argc()) { case 1: - if(ED_FLOAT(sv_player, ED_movetype) != MOVETYPE_FLY) + if(ED_Float(sv_player, ED_movetype) != MOVETYPE_FLY) { - ED_FLOAT(sv_player, ED_movetype) = MOVETYPE_FLY; + ED_Float(sv_player, ED_movetype) = MOVETYPE_FLY; SV_ClientPrintf("flymode ON\n"); } else { - ED_FLOAT(sv_player, ED_movetype) = MOVETYPE_WALK; + ED_Float(sv_player, ED_movetype) = MOVETYPE_WALK; SV_ClientPrintf("flymode OFF\n"); } break; case 2: if(atof(Cmd_Argv(1))) { - ED_FLOAT(sv_player, ED_movetype) = MOVETYPE_FLY; + ED_Float(sv_player, ED_movetype) = MOVETYPE_FLY; SV_ClientPrintf("flymode ON\n"); } else { - ED_FLOAT(sv_player, ED_movetype) = MOVETYPE_WALK; + ED_Float(sv_player, ED_movetype) = MOVETYPE_WALK; SV_ClientPrintf("flymode OFF\n"); } break; @@ -1010,7 +1010,7 @@ void Host_SavegameComment(char *text) for(i = 0; i < SAVEGAME_COMMENT_LENGTH; i++) text[i] = ' '; memcpy(text, cl.levelname, q_min(strlen(cl.levelname), 22)); //johnfitz -- only copy 22 chars. - sprintf(kills, "kills:%3" PRIi32 "/%3" PRIi32 "", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]); + sprintf(kills, "kills:%3" PRIi32 "/%3" PRIi32, cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]); memcpy(text + 22, kills, strlen(kills)); // convert space to _ to make stdio happy for(i = 0; i < SAVEGAME_COMMENT_LENGTH; i++) @@ -1069,7 +1069,7 @@ void Host_Savegame_f(void) for(i = 0 ; i < svs.maxclients ; i++) { - if(svs.clients[i].active && ED_FLOAT(svs.clients[i].edict, ED_health) <= 0) + if(svs.clients[i].active && ED_Float(svs.clients[i].edict, ED_health) <= 0) { Con_Printf("Can't savegame with a dead player\n"); return; @@ -1110,7 +1110,7 @@ void Host_Savegame_f(void) ED_WriteGlobals(f); for(i = 0; i < sv.num_edicts; i++) { - ED_Write(f, EDICT_NUM(i)); + ED_Write(f, EdictNum(i)); fflush(f); } fclose(f); @@ -1237,7 +1237,7 @@ void Host_Loadgame_f(void) else { // parse an edict - ent = EDICT_NUM(entnum); + ent = EdictNum(entnum); if(entnum < sv.num_edicts) { ent->free = false; @@ -1311,7 +1311,7 @@ void Host_Name_f(void) Con_Printf("%s renamed to %s\n", host_client->name, newName); } strcpy(host_client->name, newName); - ED_RSTRING(host_client->edict, ED_netname) = PR_SetEngineString(host_client->name); + ED_RString(host_client->edict, ED_netname) = PR_SetEngineString(host_client->name); // send notification to all clients @@ -1386,7 +1386,7 @@ void Host_Say(bool teamonly) { if(!client || !client->active || !client->spawned) continue; - if(teamplay.value && teamonly && ED_FLOAT(client->edict, ED_team) != ED_FLOAT(save->edict, ED_team)) + if(teamplay.value && teamonly && ED_Float(client->edict, ED_team) != ED_Float(save->edict, ED_team)) continue; host_client = client; SV_ClientPrintf("%s", text); @@ -1518,7 +1518,7 @@ void Host_Color_f(void) } host_client->colors = playercolor; - ED_FLOAT(host_client->edict, ED_team) = bottom + 1; + ED_Float(host_client->edict, ED_team) = bottom + 1; // send notification to all clients MSG_WriteByte(&sv.reliable_datagram, svc_updatecolors); @@ -1539,15 +1539,15 @@ void Host_Kill_f(void) return; } - if(ED_FLOAT(sv_player, ED_health) <= 0) + if(ED_Float(sv_player, ED_health) <= 0) { SV_ClientPrintf("Can't suicide -- allready dead!\n"); return; } - G_FLOAT(GBL_time) = sv.time; - G_PEDICT(GBL_self) = EDICT_TO_PROG(sv_player); - PR_ExecuteProgram(G_FUNC(GBL_ClientKill)); + G_Float(GBL_time) = sv.time; + G_PEdict(GBL_self) = EdictProg(sv_player); + PR_ExecuteProgram(G_Func(GBL_ClientKill)); } @@ -1579,11 +1579,11 @@ void Host_Pause_f(void) if(sv.paused) { - SV_BroadcastPrintf("%s paused the game\n", ED_STRING(sv_player, ED_netname)); + SV_BroadcastPrintf("%s paused the game\n", ED_String(sv_player, ED_netname)); } else { - SV_BroadcastPrintf("%s unpaused the game\n", ED_STRING(sv_player, ED_netname)); + SV_BroadcastPrintf("%s unpaused the game\n", ED_String(sv_player, ED_netname)); } // send notification to all clients @@ -1656,22 +1656,22 @@ void Host_Spawn_f(void) ent = host_client->edict; memset(ent->fields, 0, progs.entityfields * 4); - ED_FLOAT(ent, ED_colormap) = NUM_FOR_EDICT(ent); - ED_FLOAT(ent, ED_team) = (host_client->colors & 15) + 1; - ED_RSTRING(ent, ED_netname) = PR_SetEngineString(host_client->name); + ED_Float(ent, ED_colormap) = NumForEdict(ent); + ED_Float(ent, ED_team) = (host_client->colors & 15) + 1; + ED_RString(ent, ED_netname) = PR_SetEngineString(host_client->name); // copy spawn parms out of the client_t for(i = 0 ; i < NUM_SPAWN_PARMS ; i++) - (&G_FLOAT(GBL_parm1))[i] = host_client->spawn_parms[i]; + (&G_Float(GBL_parm1))[i] = host_client->spawn_parms[i]; // call the spawn function - G_FLOAT(GBL_time) = sv.time; - G_PEDICT(GBL_self) = EDICT_TO_PROG(sv_player); - PR_ExecuteProgram(G_FUNC(GBL_ClientConnect)); + G_Float(GBL_time) = sv.time; + G_PEdict(GBL_self) = EdictProg(sv_player); + PR_ExecuteProgram(G_Func(GBL_ClientConnect)); if((Sys_DoubleTime() - NET_QSocketGetTime(host_client->netconnection)) <= sv.time) Sys_Printf("%s entered the game\n", host_client->name); - PR_ExecuteProgram(G_FUNC(GBL_PutClientInServer)); + PR_ExecuteProgram(G_Func(GBL_PutClientInServer)); } @@ -1708,19 +1708,19 @@ void Host_Spawn_f(void) // MSG_WriteByte(&host_client->message, svc_updatestat); MSG_WriteByte(&host_client->message, STAT_TOTALSECRETS); - MSG_WriteLong(&host_client->message, G_FLOAT(GBL_total_secrets)); + MSG_WriteLong(&host_client->message, G_Float(GBL_total_secrets)); MSG_WriteByte(&host_client->message, svc_updatestat); MSG_WriteByte(&host_client->message, STAT_TOTALMONSTERS); - MSG_WriteLong(&host_client->message, G_FLOAT(GBL_total_monsters)); + MSG_WriteLong(&host_client->message, G_Float(GBL_total_monsters)); MSG_WriteByte(&host_client->message, svc_updatestat); MSG_WriteByte(&host_client->message, STAT_SECRETS); - MSG_WriteLong(&host_client->message, G_FLOAT(GBL_found_secrets)); + MSG_WriteLong(&host_client->message, G_Float(GBL_found_secrets)); MSG_WriteByte(&host_client->message, svc_updatestat); MSG_WriteByte(&host_client->message, STAT_MONSTERS); - MSG_WriteLong(&host_client->message, G_FLOAT(GBL_killed_monsters)); + MSG_WriteLong(&host_client->message, G_Float(GBL_killed_monsters)); // // send a fixangle @@ -1728,10 +1728,10 @@ void Host_Spawn_f(void) // in a state where it is expecting the client to correct the angle // and it won't happen if the game was just loaded, so you wind up // with a permanent head tilt - ent = EDICT_NUM(1 + (host_client - svs.clients)); + ent = EdictNum(1 + (host_client - svs.clients)); MSG_WriteByte(&host_client->message, svc_setangle); for(i = 0; i < 2; i++) - MSG_WriteAngle(&host_client->message, ED_VECTOR(ent, ED_angles)[i], sv.protocolflags); + MSG_WriteAngle(&host_client->message, ED_Vector(ent, ED_angles)[i], sv.protocolflags); MSG_WriteAngle(&host_client->message, 0, sv.protocolflags); SV_WriteClientdataToMessage(sv_player, &host_client->message); @@ -1783,7 +1783,7 @@ void Host_Kick_f(void) return; } } - else if(G_FLOAT(GBL_deathmatch)) + else if(G_Float(GBL_deathmatch)) return; save = host_client; @@ -1871,7 +1871,7 @@ void Host_Give_f(void) return; } - if(G_FLOAT(GBL_deathmatch)) + if(G_Float(GBL_deathmatch)) return; t = Cmd_Argv(1); @@ -1895,21 +1895,21 @@ void Host_Give_f(void) if(t[0] == '6') { if(t[1] == 'a') - ED_FLOAT(sv_player, ED_items) = (int32_t)ED_FLOAT(sv_player, ED_items) | HIT_PROXIMITY_GUN; + ED_Float(sv_player, ED_items) = (int32_t)ED_Float(sv_player, ED_items) | HIT_PROXIMITY_GUN; else - ED_FLOAT(sv_player, ED_items) = (int32_t)ED_FLOAT(sv_player, ED_items) | IT_GRENADE_LAUNCHER; + ED_Float(sv_player, ED_items) = (int32_t)ED_Float(sv_player, ED_items) | IT_GRENADE_LAUNCHER; } else if(t[0] == '9') - ED_FLOAT(sv_player, ED_items) = (int32_t)ED_FLOAT(sv_player, ED_items) | HIT_LASER_CANNON; + ED_Float(sv_player, ED_items) = (int32_t)ED_Float(sv_player, ED_items) | HIT_LASER_CANNON; else if(t[0] == '0') - ED_FLOAT(sv_player, ED_items) = (int32_t)ED_FLOAT(sv_player, ED_items) | HIT_MJOLNIR; + ED_Float(sv_player, ED_items) = (int32_t)ED_Float(sv_player, ED_items) | HIT_MJOLNIR; else if(t[0] >= '2') - ED_FLOAT(sv_player, ED_items) = (int32_t)ED_FLOAT(sv_player, ED_items) | (IT_SHOTGUN << (t[0] - '2')); + ED_Float(sv_player, ED_items) = (int32_t)ED_Float(sv_player, ED_items) | (IT_SHOTGUN << (t[0] - '2')); } else { if(t[0] >= '2') - ED_FLOAT(sv_player, ED_items) = (int32_t)ED_FLOAT(sv_player, ED_items) | (IT_SHOTGUN << (t[0] - '2')); + ED_Float(sv_player, ED_items) = (int32_t)ED_Float(sv_player, ED_items) | (IT_SHOTGUN << (t[0] - '2')); } break; @@ -1920,7 +1920,7 @@ void Host_Give_f(void) if(val) val->flt = v; } - ED_FLOAT(sv_player, ED_ammo_shells) = v; + ED_Float(sv_player, ED_ammo_shells) = v; break; case 'n': @@ -1930,13 +1930,13 @@ void Host_Give_f(void) if(val) { val->flt = v; - if(ED_FLOAT(sv_player, ED_weapon) <= IT_LIGHTNING) - ED_FLOAT(sv_player, ED_ammo_nails) = v; + if(ED_Float(sv_player, ED_weapon) <= IT_LIGHTNING) + ED_Float(sv_player, ED_ammo_nails) = v; } } else { - ED_FLOAT(sv_player, ED_ammo_nails) = v; + ED_Float(sv_player, ED_ammo_nails) = v; } break; @@ -1947,8 +1947,8 @@ void Host_Give_f(void) if(val) { val->flt = v; - if(ED_FLOAT(sv_player, ED_weapon) > IT_LIGHTNING) - ED_FLOAT(sv_player, ED_ammo_nails) = v; + if(ED_Float(sv_player, ED_weapon) > IT_LIGHTNING) + ED_Float(sv_player, ED_ammo_nails) = v; } } break; @@ -1960,13 +1960,13 @@ void Host_Give_f(void) if(val) { val->flt = v; - if(ED_FLOAT(sv_player, ED_weapon) <= IT_LIGHTNING) - ED_FLOAT(sv_player, ED_ammo_rockets) = v; + if(ED_Float(sv_player, ED_weapon) <= IT_LIGHTNING) + ED_Float(sv_player, ED_ammo_rockets) = v; } } else { - ED_FLOAT(sv_player, ED_ammo_rockets) = v; + ED_Float(sv_player, ED_ammo_rockets) = v; } break; @@ -1977,14 +1977,14 @@ void Host_Give_f(void) if(val) { val->flt = v; - if(ED_FLOAT(sv_player, ED_weapon) > IT_LIGHTNING) - ED_FLOAT(sv_player, ED_ammo_rockets) = v; + if(ED_Float(sv_player, ED_weapon) > IT_LIGHTNING) + ED_Float(sv_player, ED_ammo_rockets) = v; } } break; case 'h': - ED_FLOAT(sv_player, ED_health) = v; + ED_Float(sv_player, ED_health) = v; break; case 'c': @@ -1994,13 +1994,13 @@ void Host_Give_f(void) if(val) { val->flt = v; - if(ED_FLOAT(sv_player, ED_weapon) <= IT_LIGHTNING) - ED_FLOAT(sv_player, ED_ammo_cells) = v; + if(ED_Float(sv_player, ED_weapon) <= IT_LIGHTNING) + ED_Float(sv_player, ED_ammo_cells) = v; } } else { - ED_FLOAT(sv_player, ED_ammo_cells) = v; + ED_Float(sv_player, ED_ammo_cells) = v; } break; @@ -2011,8 +2011,8 @@ void Host_Give_f(void) if(val) { val->flt = v; - if(ED_FLOAT(sv_player, ED_weapon) > IT_LIGHTNING) - ED_FLOAT(sv_player, ED_ammo_cells) = v; + if(ED_Float(sv_player, ED_weapon) > IT_LIGHTNING) + ED_Float(sv_player, ED_ammo_cells) = v; } } break; @@ -2021,26 +2021,26 @@ void Host_Give_f(void) case 'a': if(v > 150) { - ED_FLOAT(sv_player, ED_armortype) = 0.8; - ED_FLOAT(sv_player, ED_armorvalue) = v; - ED_FLOAT(sv_player, ED_items) = ED_FLOAT(sv_player, ED_items) - - ((int32_t)(ED_FLOAT(sv_player, ED_items)) & (int32_t)(IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) + + ED_Float(sv_player, ED_armortype) = 0.8; + ED_Float(sv_player, ED_armorvalue) = v; + ED_Float(sv_player, ED_items) = ED_Float(sv_player, ED_items) - + ((int32_t)(ED_Float(sv_player, ED_items)) & (int32_t)(IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) + IT_ARMOR3; } else if(v > 100) { - ED_FLOAT(sv_player, ED_armortype) = 0.6; - ED_FLOAT(sv_player, ED_armorvalue) = v; - ED_FLOAT(sv_player, ED_items) = ED_FLOAT(sv_player, ED_items) - - ((int32_t)(ED_FLOAT(sv_player, ED_items)) & (int32_t)(IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) + + ED_Float(sv_player, ED_armortype) = 0.6; + ED_Float(sv_player, ED_armorvalue) = v; + ED_Float(sv_player, ED_items) = ED_Float(sv_player, ED_items) - + ((int32_t)(ED_Float(sv_player, ED_items)) & (int32_t)(IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) + IT_ARMOR2; } else if(v >= 0) { - ED_FLOAT(sv_player, ED_armortype) = 0.3; - ED_FLOAT(sv_player, ED_armorvalue) = v; - ED_FLOAT(sv_player, ED_items) = ED_FLOAT(sv_player, ED_items) - - ((int32_t)(ED_FLOAT(sv_player, ED_items)) & (int32_t)(IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) + + ED_Float(sv_player, ED_armortype) = 0.3; + ED_Float(sv_player, ED_armorvalue) = v; + ED_Float(sv_player, ED_items) = ED_Float(sv_player, ED_items) - + ((int32_t)(ED_Float(sv_player, ED_items)) & (int32_t)(IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) + IT_ARMOR1; } break; @@ -2048,37 +2048,37 @@ void Host_Give_f(void) } //johnfitz -- update currentammo to match new ammo (so statusbar updates correctly) - switch((int32_t)(ED_FLOAT(sv_player, ED_weapon))) + switch((int32_t)(ED_Float(sv_player, ED_weapon))) { case IT_SHOTGUN: case IT_SUPER_SHOTGUN: - ED_FLOAT(sv_player, ED_currentammo) = ED_FLOAT(sv_player, ED_ammo_shells); + ED_Float(sv_player, ED_currentammo) = ED_Float(sv_player, ED_ammo_shells); break; case IT_NAILGUN: case IT_SUPER_NAILGUN: case RIT_LAVA_SUPER_NAILGUN: - ED_FLOAT(sv_player, ED_currentammo) = ED_FLOAT(sv_player, ED_ammo_nails); + ED_Float(sv_player, ED_currentammo) = ED_Float(sv_player, ED_ammo_nails); break; case IT_GRENADE_LAUNCHER: case IT_ROCKET_LAUNCHER: case RIT_MULTI_GRENADE: case RIT_MULTI_ROCKET: - ED_FLOAT(sv_player, ED_currentammo) = ED_FLOAT(sv_player, ED_ammo_rockets); + ED_Float(sv_player, ED_currentammo) = ED_Float(sv_player, ED_ammo_rockets); break; case IT_LIGHTNING: case HIT_LASER_CANNON: case HIT_MJOLNIR: - ED_FLOAT(sv_player, ED_currentammo) = ED_FLOAT(sv_player, ED_ammo_cells); + ED_Float(sv_player, ED_currentammo) = ED_Float(sv_player, ED_ammo_cells); break; case RIT_LAVA_NAILGUN: //same as IT_AXE if(rogue) - ED_FLOAT(sv_player, ED_currentammo) = ED_FLOAT(sv_player, ED_ammo_nails); + ED_Float(sv_player, ED_currentammo) = ED_Float(sv_player, ED_ammo_nails); break; case RIT_PLASMA_GUN: //same as HIT_PROXIMITY_GUN if(rogue) - ED_FLOAT(sv_player, ED_currentammo) = ED_FLOAT(sv_player, ED_ammo_cells); + ED_Float(sv_player, ED_currentammo) = ED_Float(sv_player, ED_ammo_cells); if(hipnotic) - ED_FLOAT(sv_player, ED_currentammo) = ED_FLOAT(sv_player, ED_ammo_rockets); + ED_Float(sv_player, ED_currentammo) = ED_Float(sv_player, ED_ammo_rockets); break; } //johnfitz @@ -2091,8 +2091,8 @@ edict_t *FindViewthing(void) for(i = 0 ; i < sv.num_edicts ; i++) { - e = EDICT_NUM(i); - if(!strcmp(ED_STRING(e, ED_classname), "viewthing")) + e = EdictNum(i); + if(!strcmp(ED_String(e, ED_classname), "viewthing")) return e; } Con_Printf("No viewthing on map\n"); @@ -2120,8 +2120,8 @@ void Host_Viewmodel_f(void) return; } - ED_FLOAT(e, ED_frame) = 0; - cl.model_precache[(int32_t)ED_FLOAT(e, ED_modelindex)] = m; + ED_Float(e, ED_frame) = 0; + cl.model_precache[(int32_t)ED_Float(e, ED_modelindex)] = m; } /* @@ -2138,13 +2138,13 @@ void Host_Viewframe_f(void) e = FindViewthing(); if(!e) return; - m = cl.model_precache[(int32_t)ED_FLOAT(e, ED_modelindex)]; + m = cl.model_precache[(int32_t)ED_Float(e, ED_modelindex)]; f = atoi(Cmd_Argv(1)); if(f >= m->numframes) f = m->numframes - 1; - ED_FLOAT(e, ED_frame) = f; + ED_Float(e, ED_frame) = f; } @@ -2174,13 +2174,13 @@ void Host_Viewnext_f(void) e = FindViewthing(); if(!e) return; - m = cl.model_precache[(int32_t)ED_FLOAT(e, ED_modelindex)]; + m = cl.model_precache[(int32_t)ED_Float(e, ED_modelindex)]; - ED_FLOAT(e, ED_frame) = ED_FLOAT(e, ED_frame) + 1; - if(ED_FLOAT(e, ED_frame) >= m->numframes) - ED_FLOAT(e, ED_frame) = m->numframes - 1; + ED_Float(e, ED_frame) = ED_Float(e, ED_frame) + 1; + if(ED_Float(e, ED_frame) >= m->numframes) + ED_Float(e, ED_frame) = m->numframes - 1; - PrintFrameName(m, ED_FLOAT(e, ED_frame)); + PrintFrameName(m, ED_Float(e, ED_frame)); } /* @@ -2197,13 +2197,13 @@ void Host_Viewprev_f(void) if(!e) return; - m = cl.model_precache[(int32_t)ED_FLOAT(e, ED_modelindex)]; + m = cl.model_precache[(int32_t)ED_Float(e, ED_modelindex)]; - ED_FLOAT(e, ED_frame) = ED_FLOAT(e, ED_frame) - 1; - if(ED_FLOAT(e, ED_frame) < 0) - ED_FLOAT(e, ED_frame) = 0; + ED_Float(e, ED_frame) = ED_Float(e, ED_frame) - 1; + if(ED_Float(e, ED_frame) < 0) + ED_Float(e, ED_frame) = 0; - PrintFrameName(m, ED_FLOAT(e, ED_frame)); + PrintFrameName(m, ED_Float(e, ED_frame)); } /* diff --git a/source/menu.c b/source/menu.c index bcf95b4..a1bf5e0 100644 --- a/source/menu.c +++ b/source/menu.c @@ -1723,7 +1723,7 @@ void M_Menu_LanConfig_f(void) if(StartingGame && lanConfig_cursor == 2) lanConfig_cursor = 1; lanConfig_port = DEFAULTnet_hostport; - sprintf(lanConfig_portname, "%" PRIu32 "", lanConfig_port); + sprintf(lanConfig_portname, "%" PRIu32, lanConfig_port); m_return_onerror = false; m_return_reason[0] = 0; @@ -1876,7 +1876,7 @@ void M_LanConfig_Key(int32_t key) l = lanConfig_port; else lanConfig_port = l; - sprintf(lanConfig_portname, "%" PRIu32 "", lanConfig_port); + sprintf(lanConfig_portname, "%" PRIu32, lanConfig_port); } @@ -2096,7 +2096,7 @@ void M_GameOptions_Draw(void) M_Print(160, 40, "begin game"); M_Print(0, 56, " Max players"); - M_Print(160, 56, va("%" PRIi32 "", maxplayers)); + M_Print(160, 56, va("%" PRIi32, maxplayers)); M_Print(0, 64, " Game Type"); if(coop.value) diff --git a/source/net_dgrm.c b/source/net_dgrm.c index 16c196f..20e724e 100644 --- a/source/net_dgrm.c +++ b/source/net_dgrm.c @@ -89,7 +89,7 @@ static void NET_Ban_f(void) } else { - if(G_FLOAT(GBL_deathmatch)) + if(G_Float(GBL_deathmatch)) return; print_fn = SV_ClientPrintf; } @@ -945,7 +945,7 @@ static qsocket_t *Datagram_CheckNewConnections_(void) MSG_WriteByte(&net_message, playerNumber); MSG_WriteString(&net_message, client->name); MSG_WriteLong(&net_message, client->colors); - MSG_WriteLong(&net_message, (int32_t)ED_FLOAT(client->edict, ED_frags)); + MSG_WriteLong(&net_message, (int32_t)ED_Float(client->edict, ED_frags)); MSG_WriteLong(&net_message, (int32_t)(net_time - client->netconnection->connecttime)); MSG_WriteString(&net_message, client->netconnection->address); *((int32_t *)net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK)); diff --git a/source/pr_cmds.c b/source/pr_cmds.c index 04f6ee6..40ce1aa 100644 --- a/source/pr_cmds.c +++ b/source/pr_cmds.c @@ -32,7 +32,7 @@ static char *PR_GetTempString(void) return pr_string_temp[(STRINGTEMP_BUFFERS - 1) & ++pr_string_tempindex]; } -#define RETURN_EDICT(e) (G_PEDICT(GBL_RETURN) = EDICT_TO_PROG(e)) +#define RETURN_EDICT(e) (G_PEdict(GBL_RETURN) = EdictProg(e)) #define MSG_BROADCAST 0 // unreliable to all #define MSG_ONE 1 // reliable to one (msg_entity) @@ -57,7 +57,7 @@ static char *PF_VarString(int32_t first) s = 0; for(i = first; i < pr_argc; i++) { - s = q_strlcat(out, G_STRING((GBL_PARM0 + i * 3)), sizeof(out)); + s = q_strlcat(out, G_String((GBL_PARM0 + i * 3)), sizeof(out)); if(s >= sizeof(out)) { Con_Warning("PF_VarString: overflow (string truncated)\n"); @@ -94,7 +94,7 @@ static void PF_error(void) s = PF_VarString(0); Con_Printf("======SERVER ERROR in %s:\n%s\n", PR_GetString(pr_xfunction->s_name), s); - ed = PROG_TO_EDICT(G_PEDICT(GBL_self)); + ed = ProgEdict(G_PEdict(GBL_self)); ED_Print(ed); Host_Error("Program error"); @@ -118,7 +118,7 @@ static void PF_objerror(void) s = PF_VarString(0); Con_Printf("======OBJECT ERROR in %s:\n%s\n", PR_GetString(pr_xfunction->s_name), s); - ed = PROG_TO_EDICT(G_PEDICT(GBL_self)); + ed = ProgEdict(G_PEdict(GBL_self)); ED_Print(ed); ED_Free(ed); @@ -137,7 +137,7 @@ makevectors(vector) */ static void PF_makevectors(void) { - AngleVectors(G_VECTOR(GBL_PARM0), G_VECTOR(GBL_v_forward), G_VECTOR(GBL_v_right), G_VECTOR(GBL_v_up)); + AngleVectors(G_Vector(GBL_PARM0), G_Vector(GBL_v_forward), G_Vector(GBL_v_right), G_Vector(GBL_v_up)); } /* @@ -159,9 +159,9 @@ static void PF_setorigin(void) edict_t *e; float *org; - e = G_EDICT(GBL_PARM0); - org = G_VECTOR(GBL_PARM1); - VectorCopy(org, ED_VECTOR(e, ED_origin)); + e = G_Edict(GBL_PARM0); + org = G_Vector(GBL_PARM1); + VectorCopy(org, ED_Vector(e, ED_origin)); SV_LinkEdict(e, false); } @@ -190,7 +190,7 @@ static void SetMinMaxSize(edict_t *e, float *minvec, float *maxvec, bool rotate) else { // find min / max for rotations - angles = ED_VECTOR(e, ED_angles); + angles = ED_Vector(e, ED_angles); a = angles[1] / 180 * PI; @@ -233,9 +233,9 @@ static void SetMinMaxSize(edict_t *e, float *minvec, float *maxvec, bool rotate) } // set derived values - VectorCopy(rmin, ED_VECTOR(e, ED_mins)); - VectorCopy(rmax, ED_VECTOR(e, ED_maxs)); - VectorSubtract(maxvec, minvec, ED_VECTOR(e, ED_size)); + VectorCopy(rmin, ED_Vector(e, ED_mins)); + VectorCopy(rmax, ED_Vector(e, ED_maxs)); + VectorSubtract(maxvec, minvec, ED_Vector(e, ED_size)); SV_LinkEdict(e, false); } @@ -254,9 +254,9 @@ static void PF_setsize(void) edict_t *e; float *minvec, *maxvec; - e = G_EDICT(GBL_PARM0); - minvec = G_VECTOR(GBL_PARM1); - maxvec = G_VECTOR(GBL_PARM2); + e = G_Edict(GBL_PARM0); + minvec = G_Vector(GBL_PARM1); + maxvec = G_Vector(GBL_PARM2); SetMinMaxSize(e, minvec, maxvec, false); } @@ -275,8 +275,8 @@ static void PF_setmodel(void) qmodel_t *mod; edict_t *e; - e = G_EDICT(GBL_PARM0); - m = G_STRING(GBL_PARM1); + e = G_Edict(GBL_PARM0); + m = G_String(GBL_PARM1); // check to see if model was properly precached for(i = 0, check = sv.model_precache; *check; i++, check++) @@ -289,10 +289,10 @@ static void PF_setmodel(void) { PR_RunError("no precache: %s", m); } - ED_RSTRING(e, ED_model) = PR_SetEngineString(*check); - ED_FLOAT(e, ED_modelindex) = i; //SV_ModelIndex (m); + ED_RString(e, ED_model) = PR_SetEngineString(*check); + ED_Float(e, ED_modelindex) = i; //SV_ModelIndex (m); - mod = sv.models[(int32_t)ED_FLOAT(e, ED_modelindex)]; // Mod_ForName (m, true); + mod = sv.models[(int32_t)ED_Float(e, ED_modelindex)]; // Mod_ForName (m, true); if(mod) //johnfitz -- correct physics cullboxes for bmodels @@ -339,7 +339,7 @@ static void PF_sprint(void) client_t *client; int32_t entnum; - entnum = G_EDICTNUM(GBL_PARM0); + entnum = G_EdictNum(GBL_PARM0); s = PF_VarString(1); if(entnum < 1 || entnum > svs.maxclients) @@ -370,7 +370,7 @@ static void PF_centerprint(void) client_t *client; int32_t entnum; - entnum = G_EDICTNUM(GBL_PARM0); + entnum = G_EdictNum(GBL_PARM0); s = PF_VarString(1); if(entnum < 1 || entnum > svs.maxclients) @@ -399,7 +399,7 @@ static void PF_normalize(void) vec3_t newvalue; double new_temp; - value1 = G_VECTOR(GBL_PARM0); + value1 = G_Vector(GBL_PARM0); new_temp = (double)value1[0] * value1[0] + (double)value1[1] * value1[1] + (double)value1[2] * value1[2]; new_temp = sqrt(new_temp); @@ -414,7 +414,7 @@ static void PF_normalize(void) newvalue[2] = value1[2] * new_temp; } - VectorCopy(newvalue, G_VECTOR(GBL_RETURN)); + VectorCopy(newvalue, G_Vector(GBL_RETURN)); } /* @@ -429,12 +429,12 @@ static void PF_vlen(void) float *value1; double new_temp; - value1 = G_VECTOR(GBL_PARM0); + value1 = G_Vector(GBL_PARM0); new_temp = (double)value1[0] * value1[0] + (double)value1[1] * value1[1] + (double)value1[2] * value1[2]; new_temp = sqrt(new_temp); - G_FLOAT(GBL_RETURN) = new_temp; + G_Float(GBL_RETURN) = new_temp; } /* @@ -449,7 +449,7 @@ static void PF_vectoyaw(void) float *value1; float yaw; - value1 = G_VECTOR(GBL_PARM0); + value1 = G_Vector(GBL_PARM0); if(value1[1] == 0 && value1[0] == 0) yaw = 0; @@ -460,7 +460,7 @@ static void PF_vectoyaw(void) yaw += 360; } - G_FLOAT(GBL_RETURN) = yaw; + G_Float(GBL_RETURN) = yaw; } @@ -477,7 +477,7 @@ static void PF_vectoangles(void) float forward; float yaw, pitch; - value1 = G_VECTOR(GBL_PARM0); + value1 = G_Vector(GBL_PARM0); if(value1[1] == 0 && value1[0] == 0) { @@ -499,9 +499,9 @@ static void PF_vectoangles(void) pitch += 360; } - G_FLOAT(GBL_RETURN + 0) = pitch; - G_FLOAT(GBL_RETURN + 1) = yaw; - G_FLOAT(GBL_RETURN + 2) = 0; + G_Float(GBL_RETURN + 0) = pitch; + G_Float(GBL_RETURN + 1) = yaw; + G_Float(GBL_RETURN + 2) = 0; } /* @@ -519,7 +519,7 @@ static void PF_random(void) num = (rand() & 0x7fff) / ((float)0x7fff); - G_FLOAT(GBL_RETURN) = num; + G_Float(GBL_RETURN) = num; } /* @@ -535,10 +535,10 @@ static void PF_particle(void) float color; float count; - org = G_VECTOR(GBL_PARM0); - dir = G_VECTOR(GBL_PARM1); - color = G_FLOAT(GBL_PARM2); - count = G_FLOAT(GBL_PARM3); + org = G_Vector(GBL_PARM0); + dir = G_Vector(GBL_PARM1); + color = G_Float(GBL_PARM2); + count = G_Float(GBL_PARM3); SV_StartParticle(org, dir, color, count); } @@ -557,10 +557,10 @@ static void PF_ambientsound(void) int32_t i, soundnum; int32_t large = false; //johnfitz -- PROTOCOL_FITZQUAKE - pos = G_VECTOR(GBL_PARM0); - samp = G_STRING(GBL_PARM1); - vol = G_FLOAT(GBL_PARM2); - attenuation = G_FLOAT(GBL_PARM3); + pos = G_Vector(GBL_PARM0); + samp = G_String(GBL_PARM1); + vol = G_Float(GBL_PARM2); + attenuation = G_Float(GBL_PARM3); // check to see if samp was properly precached for(soundnum = 0, check = sv.sound_precache; *check; check++, soundnum++) @@ -632,20 +632,20 @@ static void PF_sound(void) int32_t volume; float attenuation; - entity = G_EDICT(GBL_PARM0); - channel = G_FLOAT(GBL_PARM1); - sample = G_STRING(GBL_PARM2); - volume = G_FLOAT(GBL_PARM3) * 255; - attenuation = G_FLOAT(GBL_PARM4); + entity = G_Edict(GBL_PARM0); + channel = G_Float(GBL_PARM1); + sample = G_String(GBL_PARM2); + volume = G_Float(GBL_PARM3) * 255; + attenuation = G_Float(GBL_PARM4); if(volume < 0 || volume > 255) - Host_Error("SV_StartSound: volume = %" PRIi32 "", volume); + Host_Error("SV_StartSound: volume = %" PRIi32, volume); if(attenuation < 0 || attenuation > 4) Host_Error("SV_StartSound: attenuation = %f", attenuation); if(channel < 0 || channel > 7) - Host_Error("SV_StartSound: channel = %" PRIi32 "", channel); + Host_Error("SV_StartSound: channel = %" PRIi32, channel); SV_StartSound(entity, channel, sample, volume, attenuation); } @@ -682,10 +682,10 @@ static void PF_traceline(void) int32_t nomonsters; edict_t *ent; - v1 = G_VECTOR(GBL_PARM0); - v2 = G_VECTOR(GBL_PARM1); - nomonsters = G_FLOAT(GBL_PARM2); - ent = G_EDICT(GBL_PARM3); + v1 = G_Vector(GBL_PARM0); + v2 = G_Vector(GBL_PARM1); + nomonsters = G_Float(GBL_PARM2); + ent = G_Edict(GBL_PARM3); /* FIXME FIXME FIXME: Why do we hit this?? */ if(developer.value) @@ -694,7 +694,7 @@ static void PF_traceline(void) isnan(v2[0]) || isnan(v2[1]) || isnan(v2[2])) { Con_Warning("NAN in traceline:\nv1(%f %f %f) v2(%f %f %f)\nentity %" PRIi32 "\n", - v1[0], v1[1], v1[2], v2[0], v2[1], v2[2], NUM_FOR_EDICT(ent)); + v1[0], v1[1], v1[2], v2[0], v2[1], v2[2], NumForEdict(ent)); } } @@ -705,18 +705,18 @@ static void PF_traceline(void) trace = SV_Move(v1, vec3_origin, vec3_origin, v2, nomonsters, ent); - G_FLOAT(GBL_trace_allsolid) = trace.allsolid; - G_FLOAT(GBL_trace_startsolid) = trace.startsolid; - G_FLOAT(GBL_trace_fraction) = trace.fraction; - G_FLOAT(GBL_trace_inwater) = trace.inwater; - G_FLOAT(GBL_trace_inopen) = trace.inopen; - VectorCopy(trace.endpos, G_VECTOR(GBL_trace_endpos)); - VectorCopy(trace.plane.normal, G_VECTOR(GBL_trace_plane_normal)); - G_FLOAT(GBL_trace_plane_dist) = trace.plane.dist; + G_Float(GBL_trace_allsolid) = trace.allsolid; + G_Float(GBL_trace_startsolid) = trace.startsolid; + G_Float(GBL_trace_fraction) = trace.fraction; + G_Float(GBL_trace_inwater) = trace.inwater; + G_Float(GBL_trace_inopen) = trace.inopen; + VectorCopy(trace.endpos, G_Vector(GBL_trace_endpos)); + VectorCopy(trace.plane.normal, G_Vector(GBL_trace_plane_normal)); + G_Float(GBL_trace_plane_dist) = trace.plane.dist; if(trace.ent) - G_PEDICT(GBL_trace_ent) = EDICT_TO_PROG(trace.ent); + G_PEdict(GBL_trace_ent) = EdictProg(trace.ent); else - G_PEDICT(GBL_trace_ent) = EDICT_TO_PROG(sv.edicts); + G_PEdict(GBL_trace_ent) = EdictProg(sv.edicts); } //============================================================================ @@ -750,16 +750,16 @@ static int32_t PF_newcheckclient(int32_t check) if(i == svs.maxclients + 1) i = 1; - ent = EDICT_NUM(i); + ent = EdictNum(i); if(i == check) break; // didn't find anything else if(ent->free) continue; - if(ED_FLOAT(ent, ED_health) <= 0) + if(ED_Float(ent, ED_health) <= 0) continue; - if((int32_t)ED_FLOAT(ent, ED_flags) & FL_NOTARGET) + if((int32_t)ED_Float(ent, ED_flags) & FL_NOTARGET) continue; // anything that is a client, or has a client as an enemy @@ -767,7 +767,7 @@ static int32_t PF_newcheckclient(int32_t check) } // get the PVS for the entity - VectorAdd(ED_VECTOR(ent, ED_origin), ED_VECTOR(ent, ED_view_ofs), org); + VectorAdd(ED_Vector(ent, ED_origin), ED_Vector(ent, ED_view_ofs), org); leaf = Mod_PointInLeaf(org, sv.worldmodel); pvs = Mod_LeafPVS(leaf, sv.worldmodel); @@ -816,16 +816,16 @@ static void PF_checkclient(void) } // return check if it might be visible - ent = EDICT_NUM(sv.lastcheck); - if(ent->free || ED_FLOAT(ent, ED_health) <= 0) + ent = EdictNum(sv.lastcheck); + if(ent->free || ED_Float(ent, ED_health) <= 0) { RETURN_EDICT(sv.edicts); return; } // if current entity can't possibly see the check entity, return 0 - self = PROG_TO_EDICT(G_PEDICT(GBL_self)); - VectorAdd(ED_VECTOR(self, ED_origin), ED_VECTOR(self, ED_view_ofs), view); + self = ProgEdict(G_PEdict(GBL_self)); + VectorAdd(ED_Vector(self, ED_origin), ED_Vector(self, ED_view_ofs), view); leaf = Mod_PointInLeaf(view, sv.worldmodel); l = (leaf - sv.worldmodel->leafs) - 1; if((l < 0) || !(checkpvs[l >> 3] & (1 << (l & 7)))) @@ -858,10 +858,10 @@ static void PF_stuffcmd(void) const char *str; client_t *old; - entnum = G_EDICTNUM(GBL_PARM0); + entnum = G_EdictNum(GBL_PARM0); if(entnum < 1 || entnum > svs.maxclients) PR_RunError("Parm 0 not a client"); - str = G_STRING(GBL_PARM1); + str = G_String(GBL_PARM1); old = host_client; host_client = &svs.clients[entnum - 1]; @@ -882,7 +882,7 @@ static void PF_localcmd(void) { const char *str; - str = G_STRING(GBL_PARM0); + str = G_String(GBL_PARM0); Cbuf_AddText(str); } @@ -897,9 +897,9 @@ static void PF_cvar(void) { const char *str; - str = G_STRING(GBL_PARM0); + str = G_String(GBL_PARM0); - G_FLOAT(GBL_RETURN) = Cvar_VariableValue(str); + G_Float(GBL_RETURN) = Cvar_VariableValue(str); } /* @@ -913,8 +913,8 @@ static void PF_cvar_set(void) { const char *var, *val; - var = G_STRING(GBL_PARM0); - val = G_STRING(GBL_PARM1); + var = G_String(GBL_PARM0); + val = G_String(GBL_PARM1); Cvar_Set(var, val); } @@ -938,22 +938,22 @@ static void PF_findradius(void) chain = (edict_t *)sv.edicts; - org = G_VECTOR(GBL_PARM0); - rad = G_FLOAT(GBL_PARM1); + org = G_Vector(GBL_PARM0); + rad = G_Float(GBL_PARM1); - ent = NEXT_EDICT(sv.edicts); - for(i = 1; i < sv.num_edicts; i++, ent = NEXT_EDICT(ent)) + ent = NextEdict(sv.edicts); + for(i = 1; i < sv.num_edicts; i++, ent = NextEdict(ent)) { if(ent->free) continue; - if(ED_FLOAT(ent, ED_solid) == SOLID_NOT) + if(ED_Float(ent, ED_solid) == SOLID_NOT) continue; for(j = 0; j < 3; j++) - eorg[j] = org[j] - (ED_VECTOR(ent, ED_origin)[j] + (ED_VECTOR(ent, ED_mins)[j] + ED_VECTOR(ent, ED_maxs)[j]) * 0.5); + eorg[j] = org[j] - (ED_Vector(ent, ED_origin)[j] + (ED_Vector(ent, ED_mins)[j] + ED_Vector(ent, ED_maxs)[j]) * 0.5); if(VectorLength(eorg) > rad) continue; - ED_PEDICT(ent, ED_chain) = EDICT_TO_PROG(chain); + ED_PEdict(ent, ED_chain) = EdictProg(chain); chain = ent; } @@ -975,20 +975,20 @@ static void PF_ftos(void) float v; char *s; - v = G_FLOAT(GBL_PARM0); + v = G_Float(GBL_PARM0); s = PR_GetTempString(); if(v == (int32_t)v) - sprintf(s, "%" PRIi32 "", (int32_t)v); + sprintf(s, "%" PRIi32, (int32_t)v); else sprintf(s, "%5.1f", v); - G_RSTRING(GBL_RETURN) = PR_SetEngineString(s); + G_RString(GBL_RETURN) = PR_SetEngineString(s); } static void PF_fabs(void) { float v; - v = G_FLOAT(GBL_PARM0); - G_FLOAT(GBL_RETURN) = fabs(v); + v = G_Float(GBL_PARM0); + G_Float(GBL_RETURN) = fabs(v); } static void PF_vtos(void) @@ -996,8 +996,8 @@ static void PF_vtos(void) char *s; s = PR_GetTempString(); - sprintf(s, "'%5.1f %5.1f %5.1f'", G_VECTOR(GBL_PARM0)[0], G_VECTOR(GBL_PARM0)[1], G_VECTOR(GBL_PARM0)[2]); - G_RSTRING(GBL_RETURN) = PR_SetEngineString(s); + sprintf(s, "'%5.1f %5.1f %5.1f'", G_Vector(GBL_PARM0)[0], G_Vector(GBL_PARM0)[1], G_Vector(GBL_PARM0)[2]); + G_RString(GBL_RETURN) = PR_SetEngineString(s); } static void PF_spawn(void) @@ -1013,7 +1013,7 @@ static void PF_remove(void) { edict_t *ed; - ed = G_EDICT(GBL_PARM0); + ed = G_Edict(GBL_PARM0); ED_Free(ed); } @@ -1026,18 +1026,18 @@ static void PF_find(void) const char *s, *t; edict_t *ed; - e = G_EDICTNUM(GBL_PARM0); - f = G_PFIELD(GBL_PARM1); - s = G_STRING(GBL_PARM2); + e = G_EdictNum(GBL_PARM0); + f = G_PField(GBL_PARM1); + s = G_String(GBL_PARM2); if(!s) PR_RunError("PF_find: bad search string"); for(e++ ; e < sv.num_edicts ; e++) { - ed = EDICT_NUM(e); + ed = EdictNum(e); if(ed->free) continue; - t = ED_STRING(ed, f); + t = ED_String(ed, f); if(!t) continue; if(!strcmp(t, s)) @@ -1059,7 +1059,7 @@ static void PR_CheckEmptyString(const char *s) static void PF_precache_file(void) { // precache_file is only used to copy files with qcc, it does nothing - G_RSTRING(GBL_RETURN) = G_RSTRING(GBL_PARM0); + G_RString(GBL_RETURN) = G_RString(GBL_PARM0); } static void PF_precache_sound(void) @@ -1070,8 +1070,8 @@ static void PF_precache_sound(void) if(sv.state != ss_loading) PR_RunError("PF_Precache_*: Precache can only be done in spawn functions"); - s = G_STRING(GBL_PARM0); - G_RSTRING(GBL_RETURN) = G_RSTRING(GBL_PARM0); + s = G_String(GBL_PARM0); + G_RString(GBL_RETURN) = G_RString(GBL_PARM0); PR_CheckEmptyString(s); for(i = 0; i < MAX_SOUNDS; i++) @@ -1095,8 +1095,8 @@ static void PF_precache_model(void) if(sv.state != ss_loading) PR_RunError("PF_Precache_*: Precache can only be done in spawn functions"); - s = G_STRING(GBL_PARM0); - G_RSTRING(GBL_RETURN) = G_RSTRING(GBL_PARM0); + s = G_String(GBL_PARM0); + G_RString(GBL_RETURN) = G_RString(GBL_PARM0); PR_CheckEmptyString(s); for(i = 0; i < MAX_MODELS; i++) @@ -1131,7 +1131,7 @@ static void PF_traceoff(void) static void PF_eprint(void) { - ED_PrintNum(G_EDICTNUM(GBL_PARM0)); + ED_PrintNum(G_EdictNum(GBL_PARM0)); } /* @@ -1149,13 +1149,13 @@ static void PF_walkmove(void) dfunction_t *oldf; int32_t oldself; - ent = PROG_TO_EDICT(G_PEDICT(GBL_self)); - yaw = G_FLOAT(GBL_PARM0); - dist = G_FLOAT(GBL_PARM1); + ent = ProgEdict(G_PEdict(GBL_self)); + yaw = G_Float(GBL_PARM0); + dist = G_Float(GBL_PARM1); - if(!((int32_t)ED_FLOAT(ent, ED_flags) & (FL_ONGROUND | FL_FLY | FL_SWIM))) + if(!((int32_t)ED_Float(ent, ED_flags) & (FL_ONGROUND | FL_FLY | FL_SWIM))) { - G_FLOAT(GBL_RETURN) = 0; + G_Float(GBL_RETURN) = 0; return; } @@ -1167,14 +1167,14 @@ static void PF_walkmove(void) // save program state, because SV_movestep may call other functions oldf = pr_xfunction; - oldself = G_PEDICT(GBL_self); + oldself = G_PEdict(GBL_self); - G_FLOAT(GBL_RETURN) = SV_movestep(ent, move, true); + G_Float(GBL_RETURN) = SV_movestep(ent, move, true); // restore program state pr_xfunction = oldf; - G_PEDICT(GBL_self) = oldself; + G_PEdict(GBL_self) = oldself; } /* @@ -1190,22 +1190,22 @@ static void PF_droptofloor(void) vec3_t end; trace_t trace; - ent = PROG_TO_EDICT(G_PEDICT(GBL_self)); + ent = ProgEdict(G_PEdict(GBL_self)); - VectorCopy(ED_VECTOR(ent, ED_origin), end); + VectorCopy(ED_Vector(ent, ED_origin), end); end[2] -= 256; - trace = SV_Move(ED_VECTOR(ent, ED_origin), ED_VECTOR(ent, ED_mins), ED_VECTOR(ent, ED_maxs), end, false, ent); + trace = SV_Move(ED_Vector(ent, ED_origin), ED_Vector(ent, ED_mins), ED_Vector(ent, ED_maxs), end, false, ent); if(trace.fraction == 1 || trace.allsolid) - G_FLOAT(GBL_RETURN) = 0; + G_Float(GBL_RETURN) = 0; else { - VectorCopy(trace.endpos, ED_VECTOR(ent, ED_origin)); + VectorCopy(trace.endpos, ED_Vector(ent, ED_origin)); SV_LinkEdict(ent, false); - ED_FLOAT(ent, ED_flags) = (int32_t)ED_FLOAT(ent, ED_flags) | FL_ONGROUND; - ED_PEDICT(ent, ED_groundentity) = EDICT_TO_PROG(trace.ent); - G_FLOAT(GBL_RETURN) = 1; + ED_Float(ent, ED_flags) = (int32_t)ED_Float(ent, ED_flags) | FL_ONGROUND; + ED_PEdict(ent, ED_groundentity) = EdictProg(trace.ent); + G_Float(GBL_RETURN) = 1; } } @@ -1223,8 +1223,8 @@ static void PF_lightstyle(void) client_t *client; int32_t j; - style = G_FLOAT(GBL_PARM0); - val = G_STRING(GBL_PARM1); + style = G_Float(GBL_PARM0); + val = G_String(GBL_PARM1); // bounds check to avoid clobbering sv struct if(style < 0 || style >= MAX_LIGHTSTYLES) @@ -1254,21 +1254,21 @@ static void PF_lightstyle(void) static void PF_rint(void) { float f; - f = G_FLOAT(GBL_PARM0); + f = G_Float(GBL_PARM0); if(f > 0) - G_FLOAT(GBL_RETURN) = (int32_t)(f + 0.5); + G_Float(GBL_RETURN) = (int32_t)(f + 0.5); else - G_FLOAT(GBL_RETURN) = (int32_t)(f - 0.5); + G_Float(GBL_RETURN) = (int32_t)(f - 0.5); } static void PF_floor(void) { - G_FLOAT(GBL_RETURN) = floor(G_FLOAT(GBL_PARM0)); + G_Float(GBL_RETURN) = floor(G_Float(GBL_PARM0)); } static void PF_ceil(void) { - G_FLOAT(GBL_RETURN) = ceil(G_FLOAT(GBL_PARM0)); + G_Float(GBL_RETURN) = ceil(G_Float(GBL_PARM0)); } @@ -1281,9 +1281,9 @@ static void PF_checkbottom(void) { edict_t *ent; - ent = G_EDICT(GBL_PARM0); + ent = G_Edict(GBL_PARM0); - G_FLOAT(GBL_RETURN) = SV_CheckBottom(ent); + G_Float(GBL_RETURN) = SV_CheckBottom(ent); } /* @@ -1295,9 +1295,9 @@ static void PF_pointcontents(void) { float *v; - v = G_VECTOR(GBL_PARM0); + v = G_Vector(GBL_PARM0); - G_FLOAT(GBL_RETURN) = SV_PointContents(v); + G_Float(GBL_RETURN) = SV_PointContents(v); } /* @@ -1312,7 +1312,7 @@ static void PF_nextent(void) int32_t i; edict_t *ent; - i = G_EDICTNUM(GBL_PARM0); + i = G_EdictNum(GBL_PARM0); while(1) { i++; @@ -1321,7 +1321,7 @@ static void PF_nextent(void) RETURN_EDICT(sv.edicts); return; } - ent = EDICT_NUM(i); + ent = EdictNum(i); if(!ent->free) { RETURN_EDICT(ent); @@ -1348,20 +1348,20 @@ static void PF_aim(void) float dist, bestdist; float speed; - ent = G_EDICT(GBL_PARM0); - speed = G_FLOAT(GBL_PARM1); + ent = G_Edict(GBL_PARM0); + speed = G_Float(GBL_PARM1); (void) speed; /* variable set but not used */ - VectorCopy(ED_VECTOR(ent, ED_origin), start); + VectorCopy(ED_Vector(ent, ED_origin), start); start[2] += 20; // try sending a trace straight - VectorCopy(G_VECTOR(GBL_v_forward), dir); + VectorCopy(G_Vector(GBL_v_forward), dir); VectorMA(start, 2048, dir, end); tr = SV_Move(start, vec3_origin, vec3_origin, end, false, ent); - if(tr.ent && ED_FLOAT(tr.ent, ED_takedamage) == DAMAGE_AIM && (!teamplay.value || ED_FLOAT(ent, ED_team) <= 0 || ED_FLOAT(ent, ED_team) != ED_FLOAT(tr.ent, ED_team))) + if(tr.ent && ED_Float(tr.ent, ED_takedamage) == DAMAGE_AIM && (!teamplay.value || ED_Float(ent, ED_team) <= 0 || ED_Float(ent, ED_team) != ED_Float(tr.ent, ED_team))) { - VectorCopy(G_VECTOR(GBL_v_forward), G_VECTOR(GBL_RETURN)); + VectorCopy(G_Vector(GBL_v_forward), G_Vector(GBL_RETURN)); return; } @@ -1370,20 +1370,20 @@ static void PF_aim(void) bestdist = sv_aim.value; bestent = NULL; - check = NEXT_EDICT(sv.edicts); - for(i = 1; i < sv.num_edicts; i++, check = NEXT_EDICT(check)) + check = NextEdict(sv.edicts); + for(i = 1; i < sv.num_edicts; i++, check = NextEdict(check)) { - if(ED_FLOAT(check, ED_takedamage) != DAMAGE_AIM) + if(ED_Float(check, ED_takedamage) != DAMAGE_AIM) continue; if(check == ent) continue; - if(teamplay.value && ED_FLOAT(ent, ED_team) > 0 && ED_FLOAT(ent, ED_team) == ED_FLOAT(check, ED_team)) + if(teamplay.value && ED_Float(ent, ED_team) > 0 && ED_Float(ent, ED_team) == ED_Float(check, ED_team)) continue; // don't aim at teammate for(j = 0; j < 3; j++) - end[j] = ED_VECTOR(check, ED_origin)[j] + 0.5 * (ED_VECTOR(check, ED_mins)[j] + ED_VECTOR(check, ED_maxs)[j]); + end[j] = ED_Vector(check, ED_origin)[j] + 0.5 * (ED_Vector(check, ED_mins)[j] + ED_Vector(check, ED_maxs)[j]); VectorSubtract(end, start, dir); VectorNormalize(dir); - dist = DotProduct(dir, G_VECTOR(GBL_v_forward)); + dist = DotProduct(dir, G_Vector(GBL_v_forward)); if(dist < bestdist) continue; // to far to turn tr = SV_Move(start, vec3_origin, vec3_origin, end, false, ent); @@ -1397,16 +1397,16 @@ static void PF_aim(void) if(bestent) { - VectorSubtract(ED_VECTOR(bestent, ED_origin), ED_VECTOR(ent, ED_origin), dir); - dist = DotProduct(dir, G_VECTOR(GBL_v_forward)); - VectorScale(G_VECTOR(GBL_v_forward), dist, end); + VectorSubtract(ED_Vector(bestent, ED_origin), ED_Vector(ent, ED_origin), dir); + dist = DotProduct(dir, G_Vector(GBL_v_forward)); + VectorScale(G_Vector(GBL_v_forward), dist, end); end[2] = dir[2]; VectorNormalize(end); - VectorCopy(end, G_VECTOR(GBL_RETURN)); + VectorCopy(end, G_Vector(GBL_RETURN)); } else { - VectorCopy(bestdir, G_VECTOR(GBL_RETURN)); + VectorCopy(bestdir, G_Vector(GBL_RETURN)); } } @@ -1422,10 +1422,10 @@ void PF_changeyaw(void) edict_t *ent; float ideal, current, move, speed; - ent = PROG_TO_EDICT(G_PEDICT(GBL_self)); - current = anglemod(ED_VECTOR(ent, ED_angles)[1]); - ideal = ED_FLOAT(ent, ED_ideal_yaw); - speed = ED_FLOAT(ent, ED_yaw_speed); + ent = ProgEdict(G_PEdict(GBL_self)); + current = anglemod(ED_Vector(ent, ED_angles)[1]); + ideal = ED_Float(ent, ED_ideal_yaw); + speed = ED_Float(ent, ED_yaw_speed); if(current == ideal) return; @@ -1451,7 +1451,7 @@ void PF_changeyaw(void) move = -speed; } - ED_VECTOR(ent, ED_angles)[1] = anglemod(current + move); + ED_Vector(ent, ED_angles)[1] = anglemod(current + move); } /* @@ -1468,15 +1468,15 @@ static sizebuf_t *WriteDest(void) int32_t dest; edict_t *ent; - dest = G_FLOAT(GBL_PARM0); + dest = G_Float(GBL_PARM0); switch(dest) { case MSG_BROADCAST: return &sv.datagram; case MSG_ONE: - ent = PROG_TO_EDICT(G_PEDICT(GBL_msg_entity)); - entnum = NUM_FOR_EDICT(ent); + ent = ProgEdict(G_PEdict(GBL_msg_entity)); + entnum = NumForEdict(ent); if(entnum < 1 || entnum > svs.maxclients) PR_RunError("WriteDest: not a client"); return &svs.clients[entnum - 1].message; @@ -1497,42 +1497,42 @@ static sizebuf_t *WriteDest(void) static void PF_WriteByte(void) { - MSG_WriteByte(WriteDest(), G_FLOAT(GBL_PARM1)); + MSG_WriteByte(WriteDest(), G_Float(GBL_PARM1)); } static void PF_WriteChar(void) { - MSG_WriteChar(WriteDest(), G_FLOAT(GBL_PARM1)); + MSG_WriteChar(WriteDest(), G_Float(GBL_PARM1)); } static void PF_WriteShort(void) { - MSG_WriteShort(WriteDest(), G_FLOAT(GBL_PARM1)); + MSG_WriteShort(WriteDest(), G_Float(GBL_PARM1)); } static void PF_WriteLong(void) { - MSG_WriteLong(WriteDest(), G_FLOAT(GBL_PARM1)); + MSG_WriteLong(WriteDest(), G_Float(GBL_PARM1)); } static void PF_WriteAngle(void) { - MSG_WriteAngle(WriteDest(), G_FLOAT(GBL_PARM1), sv.protocolflags); + MSG_WriteAngle(WriteDest(), G_Float(GBL_PARM1), sv.protocolflags); } static void PF_WriteCoord(void) { - MSG_WriteCoord(WriteDest(), G_FLOAT(GBL_PARM1), sv.protocolflags); + MSG_WriteCoord(WriteDest(), G_Float(GBL_PARM1), sv.protocolflags); } static void PF_WriteString(void) { - MSG_WriteString(WriteDest(), G_STRING(GBL_PARM1)); + MSG_WriteString(WriteDest(), G_String(GBL_PARM1)); } static void PF_WriteEntity(void) { - MSG_WriteShort(WriteDest(), G_EDICTNUM(GBL_PARM1)); + MSG_WriteShort(WriteDest(), G_EdictNum(GBL_PARM1)); } //============================================================================= @@ -1543,7 +1543,7 @@ static void PF_makestatic(void) int32_t i; int32_t bits = 0; //johnfitz -- PROTOCOL_FITZQUAKE - ent = G_EDICT(GBL_PARM0); + ent = G_Edict(GBL_PARM0); //johnfitz -- don't send invisible static entities if(ent->alpha == ENTALPHA_ZERO) @@ -1556,7 +1556,7 @@ static void PF_makestatic(void) //johnfitz -- PROTOCOL_FITZQUAKE if(sv.protocol == PROTOCOL_NETQUAKE) { - if(SV_ModelIndex(ED_STRING(ent, ED_model)) & 0xFF00 || (int32_t)(ED_FLOAT(ent, ED_frame)) & 0xFF00) + if(SV_ModelIndex(ED_String(ent, ED_model)) & 0xFF00 || (int32_t)(ED_Float(ent, ED_frame)) & 0xFF00) { ED_Free(ent); return; //can't display the correct model & frame, so don't show it at all @@ -1564,9 +1564,9 @@ static void PF_makestatic(void) } else { - if(SV_ModelIndex(ED_STRING(ent, ED_model)) & 0xFF00) + if(SV_ModelIndex(ED_String(ent, ED_model)) & 0xFF00) bits |= B_LARGEMODEL; - if((int32_t)(ED_FLOAT(ent, ED_frame)) & 0xFF00) + if((int32_t)(ED_Float(ent, ED_frame)) & 0xFF00) bits |= B_LARGEFRAME; if(ent->alpha != ENTALPHA_DEFAULT) bits |= B_ALPHA; @@ -1581,22 +1581,22 @@ static void PF_makestatic(void) MSG_WriteByte(&sv.signon, svc_spawnstatic); if(bits & B_LARGEMODEL) - MSG_WriteShort(&sv.signon, SV_ModelIndex(ED_STRING(ent, ED_model))); + MSG_WriteShort(&sv.signon, SV_ModelIndex(ED_String(ent, ED_model))); else - MSG_WriteByte(&sv.signon, SV_ModelIndex(ED_STRING(ent, ED_model))); + MSG_WriteByte(&sv.signon, SV_ModelIndex(ED_String(ent, ED_model))); if(bits & B_LARGEFRAME) - MSG_WriteShort(&sv.signon, ED_FLOAT(ent, ED_frame)); + MSG_WriteShort(&sv.signon, ED_Float(ent, ED_frame)); else - MSG_WriteByte(&sv.signon, ED_FLOAT(ent, ED_frame)); + MSG_WriteByte(&sv.signon, ED_Float(ent, ED_frame)); //johnfitz - MSG_WriteByte(&sv.signon, ED_FLOAT(ent, ED_colormap)); - MSG_WriteByte(&sv.signon, ED_FLOAT(ent, ED_skin)); + MSG_WriteByte(&sv.signon, ED_Float(ent, ED_colormap)); + MSG_WriteByte(&sv.signon, ED_Float(ent, ED_skin)); for(i = 0; i < 3; i++) { - MSG_WriteCoord(&sv.signon, ED_VECTOR(ent, ED_origin)[i], sv.protocolflags); - MSG_WriteAngle(&sv.signon, ED_VECTOR(ent, ED_angles)[i], sv.protocolflags); + MSG_WriteCoord(&sv.signon, ED_Vector(ent, ED_origin)[i], sv.protocolflags); + MSG_WriteAngle(&sv.signon, ED_Vector(ent, ED_angles)[i], sv.protocolflags); } //johnfitz -- PROTOCOL_FITZQUAKE @@ -1621,8 +1621,8 @@ static void PF_setspawnparms(void) int32_t i; client_t *client; - ent = G_EDICT(GBL_PARM0); - i = NUM_FOR_EDICT(ent); + ent = G_Edict(GBL_PARM0); + i = NumForEdict(ent); if(i < 1 || i > svs.maxclients) PR_RunError("Entity is not a client"); @@ -1630,7 +1630,7 @@ static void PF_setspawnparms(void) client = svs.clients + (i - 1); for(i = 0; i < NUM_SPAWN_PARMS; i++) - (&G_FLOAT(GBL_parm1))[i] = client->spawn_parms[i]; + (&G_Float(GBL_parm1))[i] = client->spawn_parms[i]; } /* @@ -1647,7 +1647,7 @@ static void PF_changelevel(void) return; svs.changelevel_issued = true; - s = G_STRING(GBL_PARM0); + s = G_String(GBL_PARM0); Cbuf_AddText(va("changelevel %s\n", s)); } diff --git a/source/pr_edict.c b/source/pr_edict.c index 152ff82..64a6bc6 100644 --- a/source/pr_edict.c +++ b/source/pr_edict.c @@ -93,7 +93,7 @@ edict_t *ED_Alloc(void) for(i = svs.maxclients + 1; i < sv.num_edicts; i++) { - e = EDICT_NUM(i); + e = EdictNum(i); // the first couple seconds of server time can involve a lot of // freeing and allocating, so relax the replacement policy if(e->free && (e->freetime < 2 || sv.time - e->freetime > 0.5)) @@ -107,7 +107,7 @@ edict_t *ED_Alloc(void) Host_Error("ED_Alloc: no free edicts (max_edicts is %" PRIi32 ")", sv.max_edicts); sv.num_edicts++; - e = EDICT_NUM(i); + e = EdictNum(i); memset(e, 0, pr_edict_size); // ericw -- switched sv.edicts to malloc(), so we are accessing uninitialized memory and must fully zero it, not just ED_ClearEdict return e; @@ -126,16 +126,16 @@ void ED_Free(edict_t *ed) SV_UnlinkEdict(ed); // unlink from world bsp ed->free = true; - ED_RSTRING(ed, ED_model) = 0; - ED_FLOAT(ed, ED_takedamage) = 0; - ED_FLOAT(ed, ED_modelindex) = 0; - ED_FLOAT(ed, ED_colormap) = 0; - ED_FLOAT(ed, ED_skin) = 0; - ED_FLOAT(ed, ED_frame) = 0; - VectorCopy(vec3_origin, ED_VECTOR(ed, ED_origin)); - VectorCopy(vec3_origin, ED_VECTOR(ed, ED_angles)); - ED_FLOAT(ed, ED_nextthink) = -1; - ED_FLOAT(ed, ED_solid) = 0; + ED_RString(ed, ED_model) = 0; + ED_Float(ed, ED_takedamage) = 0; + ED_Float(ed, ED_modelindex) = 0; + ED_Float(ed, ED_colormap) = 0; + ED_Float(ed, ED_skin) = 0; + ED_Float(ed, ED_frame) = 0; + VectorCopy(vec3_origin, ED_Vector(ed, ED_origin)); + VectorCopy(vec3_origin, ED_Vector(ed, ED_angles)); + ED_Float(ed, ED_nextthink) = -1; + ED_Float(ed, ED_solid) = 0; ed->alpha = ENTALPHA_DEFAULT; //johnfitz -- reset alpha for next entity ed->freetime = sv.time; @@ -273,7 +273,7 @@ done: if(!def) return NULL; - return ED_EVAL(ed, def->ofs); + return ED_Eval(ed, def->ofs); } @@ -298,7 +298,7 @@ void ED_Print(edict_t *ed) return; } - Con_SafePrintf("\nEDICT %" PRIi32 ":\n", NUM_FOR_EDICT(ed)); //johnfitz -- was Con_Printf + Con_SafePrintf("\nEDICT %" PRIi32 ":\n", NumForEdict(ed)); //johnfitz -- was Con_Printf for(i = 1; i < progs.numfielddefs; i++) { d = &pr_fielddefs[i]; @@ -307,7 +307,7 @@ void ED_Print(edict_t *ed) if(l > 1 && name[l - 2] == '_') continue; // skip _x, _y, _z vars - v = &ED_INT(ed, d->ofs); + v = &ED_Int(ed, d->ofs); // if the value is still all 0, skip the field type = d->type & ~DEF_SAVEGLOBAL; @@ -358,7 +358,7 @@ void ED_Write(FILE *f, edict_t *ed) if(j > 1 && name[j - 2] == '_') continue; // skip _x, _y, _z vars - v = &ED_INT(ed, d->ofs); + v = &ED_Int(ed, d->ofs); // if the value is still all 0, skip the field type = d->type & ~DEF_SAVEGLOBAL; @@ -384,7 +384,7 @@ void ED_Write(FILE *f, edict_t *ed) void ED_PrintNum(int32_t ent) { - ED_Print(EDICT_NUM(ent)); + ED_Print(EdictNum(ent)); } /* @@ -447,15 +447,15 @@ static void ED_Count(void) active = models = solid = step = 0; for(i = 0; i < sv.num_edicts; i++) { - ent = EDICT_NUM(i); + ent = EdictNum(i); if(ent->free) continue; active++; - if(ED_FLOAT(ent, ED_solid)) + if(ED_Float(ent, ED_solid)) solid++; - if(ED_RSTRING(ent, ED_model)) + if(ED_RString(ent, ED_model)) models++; - if(ED_FLOAT(ent, ED_movetype) == MOVETYPE_STEP) + if(ED_Float(ent, ED_movetype) == MOVETYPE_STEP) step++; } @@ -502,7 +502,7 @@ void ED_WriteGlobals(FILE *f) name = PR_GetString(def->s_name); fprintf(f, "\"%s\" ", name); - fprintf(f, "\"%s\"\n", PR_UglyValueString(type, G_EVAL(def->ofs))); + fprintf(f, "\"%s\"\n", PR_UglyValueString(type, G_Eval(def->ofs))); } fprintf(f, "}\n"); } @@ -637,7 +637,7 @@ bool ED_ParseEpair(void *base, ddef_t *key, const char *s) break; case ev_entity: - *(int32_t *)d = EDICT_TO_PROG(EDICT_NUM(atoi(s))); + *(int32_t *)d = EdictProg(EdictNum(atoi(s))); break; case ev_field: @@ -649,7 +649,7 @@ bool ED_ParseEpair(void *base, ddef_t *key, const char *s) Con_DPrintf("Can't find field %s\n", s); return false; } - *(int32_t *)d = G_INT(def->ofs); + *(int32_t *)d = G_Int(def->ofs); break; case ev_function: @@ -792,7 +792,7 @@ void ED_LoadFromFile(const char *data) edict_t *ent = NULL; int32_t inhibit = 0; - G_FLOAT(GBL_time) = sv.time; + G_Float(GBL_time) = sv.time; // parse ents while(1) @@ -805,7 +805,7 @@ void ED_LoadFromFile(const char *data) Host_Error("ED_LoadFromFile: found %s when expecting {", com_token); if(!ent) - ent = EDICT_NUM(0); + ent = EdictNum(0); else ent = ED_Alloc(); data = ED_ParseEdict(data, ent); @@ -813,16 +813,16 @@ void ED_LoadFromFile(const char *data) // remove things from different skill levels or deathmatch if(deathmatch.value) { - if(((int32_t)ED_FLOAT(ent, ED_spawnflags) & SPAWNFLAG_NOT_DEATHMATCH)) + if(((int32_t)ED_Float(ent, ED_spawnflags) & SPAWNFLAG_NOT_DEATHMATCH)) { ED_Free(ent); inhibit++; continue; } } - else if((current_skill == 0 && ((int32_t)ED_FLOAT(ent, ED_spawnflags) & SPAWNFLAG_NOT_EASY)) - || (current_skill == 1 && ((int32_t)ED_FLOAT(ent, ED_spawnflags) & SPAWNFLAG_NOT_MEDIUM)) - || (current_skill >= 2 && ((int32_t)ED_FLOAT(ent, ED_spawnflags) & SPAWNFLAG_NOT_HARD))) + else if((current_skill == 0 && ((int32_t)ED_Float(ent, ED_spawnflags) & SPAWNFLAG_NOT_EASY)) + || (current_skill == 1 && ((int32_t)ED_Float(ent, ED_spawnflags) & SPAWNFLAG_NOT_MEDIUM)) + || (current_skill >= 2 && ((int32_t)ED_Float(ent, ED_spawnflags) & SPAWNFLAG_NOT_HARD))) { ED_Free(ent); inhibit++; @@ -832,7 +832,7 @@ void ED_LoadFromFile(const char *data) // // immediately call spawn function // - if(!ED_RSTRING(ent, ED_classname)) + if(!ED_RString(ent, ED_classname)) { Con_SafePrintf("No classname for:\n"); //johnfitz -- was Con_Printf ED_Print(ent); @@ -841,7 +841,7 @@ void ED_LoadFromFile(const char *data) } // look for the spawn function - func = ED_FindFunction(ED_STRING(ent, ED_classname)); + func = ED_FindFunction(ED_String(ent, ED_classname)); if(!func) { @@ -851,7 +851,7 @@ void ED_LoadFromFile(const char *data) continue; } - G_PEDICT(GBL_self) = EDICT_TO_PROG(ent); + G_PEdict(GBL_self) = EdictProg(ent); PR_ExecuteProgram(func - pr_functions); } @@ -874,31 +874,31 @@ void ED_Init(void) Cmd_AddCommand("edictcount", ED_Count); } -edict_t *EDICT_NUM(int32_t n) +edict_t *EdictNum(int32_t n) { if(n < 0 || n >= sv.max_edicts) - Host_Error("EDICT_NUM: bad number %" PRIi32 "", n); - return PROG_TO_EDICT(n * pr_edict_size); + Host_Error("EdictNum: bad number %" PRIi32, n); + return ProgEdict(n * pr_edict_size); } -int32_t NUM_FOR_EDICT(edict_t *e) +int32_t NumForEdict(edict_t *e) { int32_t b; - b = EDICT_TO_PROG(e); + b = EdictProg(e); b = b / pr_edict_size; if(b < 0 || b >= sv.num_edicts) - Host_Error("NUM_FOR_EDICT: bad pointer"); + Host_Error("NumForEdict: bad pointer"); return b; } -pedict_t EDICT_TO_PROG(void *e) +pedict_t EdictProg(void *e) { return (byte *)e - (byte *)sv.edicts; } -void *PROG_TO_EDICT(pedict_t e) +void *ProgEdict(pedict_t e) { return (byte *)sv.edicts + e; } diff --git a/source/pr_edict.h b/source/pr_edict.h index b4f4597..3072b67 100644 --- a/source/pr_edict.h +++ b/source/pr_edict.h @@ -26,18 +26,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define EDICT_FROM_AREA(l) (edict_t *)((byte *)(l) - offsetof(edict_t, area)) -#define ED_FLOAT(e, o) (((float *)((edict_t *)e)->fields)[o]) -#define ED_INT(e, o) (((int32_t *)((edict_t *)e)->fields)[o]) -#define ED_EDICT(e, o) PROG_TO_EDICT(ED_INT(e, o)) -#define ED_EDICTNUM(e, o) NUM_FOR_EDICT(ED_EDICT(e, o)) -#define ED_VECTOR(e, o) (&ED_FLOAT(e, o)) -#define ED_STRING(e, o) PR_GetString(ED_RSTRING(e, o)) -#define ED_RSTRING(e, o) (*(string_t *)&ED_INT(e, o)) -#define ED_FUNC(e, o) (*(func_t *)&ED_INT(e, o)) -#define ED_PEDICT(e, o) (*(pedict_t *)&ED_INT(e, o)) -#define ED_PFIELD(e, o) (*(pfield_t *)&ED_INT(e, o)) -#define ED_EVAL(e, o) ((eval_t *)&ED_INT(e, o)) -#define ED_VOID(e, o) ((void *)&ED_INT(o)) +#define ED_Float(e, o) (((float *)((edict_t *)e)->fields)[o]) +#define ED_Int(e, o) (((int32_t *)((edict_t *)e)->fields)[o]) +#define ED_Edict(e, o) ProgEdict(ED_Int(e, o)) +#define ED_EdictNum(e, o) NumForEdict(ED_Edict(e, o)) +#define ED_Vector(e, o) (&ED_Float(e, o)) +#define ED_String(e, o) PR_GetString(ED_RString(e, o)) +#define ED_RString(e, o) (*(string_t *)&ED_Int(e, o)) +#define ED_Func(e, o) (*(func_t *)&ED_Int(e, o)) +#define ED_PEdict(e, o) (*(pedict_t *)&ED_Int(e, o)) +#define ED_PField(e, o) (*(pfield_t *)&ED_Int(e, o)) +#define ED_Eval(e, o) ((eval_t *)&ED_Int(e, o)) +#define ED_Void(e, o) ((void *)&ED_Int(o)) enum { @@ -170,14 +170,14 @@ void ED_PrintNum(int32_t ent); eval_t *GetEdictFieldValue(edict_t *ed, const char *field); -static inline edict_t *NEXT_EDICT(edict_t *e) +static inline edict_t *NextEdict(edict_t *e) { return (edict_t *)((byte *)e + pr_edict_size); } -pedict_t EDICT_TO_PROG(void *e); -void *PROG_TO_EDICT(pedict_t e); -edict_t *EDICT_NUM(int32_t n); -int32_t NUM_FOR_EDICT(edict_t *e); +pedict_t EdictProg(void *e); +void *ProgEdict(pedict_t e); +edict_t *EdictNum(int32_t n); +int32_t NumForEdict(edict_t *e); #endif diff --git a/source/pr_exec.c b/source/pr_exec.c index c140010..eaf49ad 100644 --- a/source/pr_exec.c +++ b/source/pr_exec.c @@ -42,91 +42,8 @@ int32_t pr_argc; static const char *pr_opnames[] = { - "DONE", - - "MUL_F", - "MUL_V", - "MUL_FV", - "MUL_VF", - - "DIV", - - "ADD_F", - "ADD_V", - - "SUB_F", - "SUB_V", - - "EQ_F", - "EQ_V", - "EQ_S", - "EQ_E", - "EQ_FNC", - - "NE_F", - "NE_V", - "NE_S", - "NE_E", - "NE_FNC", - - "LE", - "GE", - "LT", - "GT", - - "INDIRECT", - "INDIRECT", - "INDIRECT", - "INDIRECT", - "INDIRECT", - "INDIRECT", - - "ADDRESS", - - "STORE_F", - "STORE_V", - "STORE_S", - "STORE_ENT", - "STORE_FLD", - "STORE_FNC", - - "STOREP_F", - "STOREP_V", - "STOREP_S", - "STOREP_ENT", - "STOREP_FLD", - "STOREP_FNC", - - "RETURN", - - "NOT_F", - "NOT_V", - "NOT_S", - "NOT_ENT", - "NOT_FNC", - - "IF", - "IFNOT", - - "CALL0", - "CALL1", - "CALL2", - "CALL3", - "CALL4", - "CALL5", - "CALL6", - "CALL7", - "CALL8", - - "STATE", - - "GOTO", - - "AND", - "OR", - - "BITAND", - "BITOR" +#define pr_ops__xmac(x) #x, +#include "pr_ops.h" }; const char *PR_GlobalString(int32_t ofs); @@ -153,10 +70,10 @@ static void PR_PrintStatement(dstatement_t *s) } if(s->op == OP_IF || s->op == OP_IFNOT) - Con_Printf("%sbranch %" PRIi32 "", PR_GlobalString(s->a), s->b); + Con_Printf("%sbranch %" PRIi32, PR_GlobalString(s->a), s->b); else if(s->op == OP_GOTO) { - Con_Printf("branch %" PRIi32 "", s->a); + Con_Printf("branch %" PRIi32, s->a); } else if((uint32_t)(s->op - OP_STORE_F) < 6) { @@ -297,7 +214,7 @@ static int32_t PR_EnterFunction(dfunction_t *f) PR_RunError("PR_ExecuteProgram: locals stack overflow\n"); for(i = 0; i < c ; i++) - localstack[localstack_used + i] = G_INT(f->parm_start + i); + localstack[localstack_used + i] = G_Int(f->parm_start + i); localstack_used += c; // copy parameters @@ -306,7 +223,7 @@ static int32_t PR_EnterFunction(dfunction_t *f) { for(j = 0; j < f->parm_size[i]; j++) { - G_INT(o) = G_INT(GBL_PARM0 + i * 3 + j); + G_Int(o) = G_Int(GBL_PARM0 + i * 3 + j); o++; } } @@ -334,7 +251,7 @@ static int32_t PR_LeaveFunction(void) PR_RunError("PR_ExecuteProgram: locals stack underflow"); for(i = 0; i < c; i++) - G_INT(pr_xfunction->parm_start + i) = localstack[localstack_used + i]; + G_Int(pr_xfunction->parm_start + i) = localstack[localstack_used + i]; // up stack pr_depth--; @@ -352,6 +269,48 @@ The interpretation main loop */ void PR_ExecuteProgram(func_t fnum) { +#if HAVE_COMPUTED_GOTO +#define CASE(op) oper_##op: +#define BREAK goto oper_end; +#define GOTO_OP(op) goto *oper_list[op]; +#define END_GOTO_OP oper_end:; +#else +#define CASE(op) case op: +#define BREAK break; +#define GOTO_OP(op) switch(op) { +#define END_GOTO_OP } +#endif + +#define OPA G_Eval((uint16_t)st->a) +#define OPB G_Eval((uint16_t)st->b) +#define OPC G_Eval((uint16_t)st->c) +#define PTR ((eval_t *)ProgEdict(OPB->edict)) +#define EDI ProgEdict(OPA->edict) + +#define MakeOpArithF(op, exp) \ + CASE(op) \ + OPC->flt = OPA->flt exp OPB->flt; \ + BREAK + +#define MakeOpArithV(op, exp) \ + CASE(op) \ + OPC->vec[0] = OPA->vec[0] exp OPB->vec[0]; \ + OPC->vec[1] = OPA->vec[1] exp OPB->vec[1]; \ + OPC->vec[2] = OPA->vec[2] exp OPB->vec[2]; \ + BREAK + +#define MakeOpArithB(op, exp) \ + CASE(op) \ + OPC->flt = (int32_t)OPA->flt exp (int32_t)OPB->flt; \ + BREAK + +#if HAVE_COMPUTED_GOTO + static void const *const oper_list[] = { +#define pr_ops__xmac(x) &&oper_OP_##x, +#include "pr_ops.h" + }; +#endif + dstatement_t *st; dfunction_t *f, *newf; int32_t profile, startprofile; @@ -360,8 +319,8 @@ void PR_ExecuteProgram(func_t fnum) if(!fnum || fnum >= progs.numfunctions) { - if(G_PEDICT(GBL_self)) - ED_Print(PROG_TO_EDICT(G_PEDICT(GBL_self))); + if(G_PEdict(GBL_self)) + ED_Print(ProgEdict(G_PEdict(GBL_self))); Host_Error("PR_ExecuteProgram: NULL function"); } @@ -375,7 +334,7 @@ void PR_ExecuteProgram(func_t fnum) st = &pr_statements[PR_EnterFunction(f)]; startprofile = profile = 0; - while(1) + for(;;) { /* next statement */ st++; @@ -389,30 +348,7 @@ void PR_ExecuteProgram(func_t fnum) if(pr_trace) PR_PrintStatement(st); - switch(st->op) - { -#define OPA G_EVAL((uint16_t)st->a) -#define OPB G_EVAL((uint16_t)st->b) -#define OPC G_EVAL((uint16_t)st->c) -#define PTR ((eval_t *)PROG_TO_EDICT(OPB->edict)) - -#define MakeOpArithF(op, exp) \ - case op: \ - OPC->flt = OPA->flt exp OPB->flt; \ - break; - -#define MakeOpArithV(op, exp) \ - case op: \ - OPC->vec[0] = OPA->vec[0] exp OPB->vec[0]; \ - OPC->vec[1] = OPA->vec[1] exp OPB->vec[1]; \ - OPC->vec[2] = OPA->vec[2] exp OPB->vec[2]; \ - break; - -#define MakeOpArithB(op, exp) \ - case op: \ - OPC->flt = (int32_t)OPA->flt exp (int32_t)OPB->flt; \ - break; - + GOTO_OP(st->op) MakeOpArithF(OP_ADD_F, +) MakeOpArithF(OP_SUB_F, -) MakeOpArithF(OP_MUL_F, *) @@ -424,9 +360,9 @@ void PR_ExecuteProgram(func_t fnum) MakeOpArithB(OP_BITAND, &) MakeOpArithB(OP_BITOR, |) - case OP_MUL_V: OPC->flt = DotProduct(OPA->vec, OPB->vec); break; - case OP_MUL_FV: VectorScale(OPB->vec, OPA->flt, OPC->vec); break; - case OP_MUL_VF: VectorScale(OPA->vec, OPB->flt, OPC->vec); break; + CASE(OP_MUL_V) OPC->flt = DotProduct(OPA->vec, OPB->vec); BREAK + CASE(OP_MUL_FV) VectorScale(OPB->vec, OPA->flt, OPC->vec); BREAK + CASE(OP_MUL_VF) VectorScale(OPA->vec, OPB->flt, OPC->vec); BREAK MakeOpArithF(OP_GE, >=) MakeOpArithF(OP_LE, <=) @@ -437,107 +373,91 @@ void PR_ExecuteProgram(func_t fnum) MakeOpArithF(OP_EQ_F, ==) MakeOpArithF(OP_NE_F, !=) - case OP_NOT_F: + CASE(OP_NOT_F) OPC->flt = !OPA->flt; - break; - case OP_NOT_V: + BREAK + CASE(OP_NOT_V) OPC->flt = !OPA->vec[0] && !OPA->vec[1] && !OPA->vec[2]; - break; - case OP_NOT_S: + BREAK + CASE(OP_NOT_S) OPC->flt = !OPA->string || !*PR_GetString(OPA->string); - break; - case OP_NOT_FNC: + BREAK + CASE(OP_NOT_FNC) OPC->flt = !OPA->func; - break; - case OP_NOT_ENT: - OPC->flt = PROG_TO_EDICT(OPA->edict) == sv.edicts; - break; + BREAK + CASE(OP_NOT_ENT) + OPC->flt = EDI == sv.edicts; + BREAK - case OP_EQ_V: + CASE(OP_EQ_V) OPC->flt = OPA->vec[0] == OPB->vec[0] && OPA->vec[1] == OPB->vec[1] && OPA->vec[2] == OPB->vec[2]; - break; - case OP_EQ_S: + BREAK + CASE(OP_EQ_S) OPC->flt = !strcmp(PR_GetString(OPA->string), PR_GetString(OPB->string)); - break; - case OP_EQ_E: OPC->flt = OPA->edict == OPB->edict; break; - case OP_EQ_FNC: OPC->flt = OPA->func == OPB->func; break; + BREAK + CASE(OP_EQ_E) OPC->flt = OPA->edict == OPB->edict; BREAK + CASE(OP_EQ_FNC) OPC->flt = OPA->func == OPB->func; BREAK - case OP_NE_V: + CASE(OP_NE_V) OPC->flt = OPA->vec[0] != OPB->vec[0] || OPA->vec[1] != OPB->vec[1] || OPA->vec[2] != OPB->vec[2]; - break; - case OP_NE_S: + BREAK + CASE(OP_NE_S) OPC->flt = strcmp(PR_GetString(OPA->string), PR_GetString(OPB->string)); - break; - case OP_NE_E: OPC->flt = OPA->edict != OPB->edict; break; - case OP_NE_FNC: OPC->flt = OPA->func != OPB->func; break; + BREAK + CASE(OP_NE_E) OPC->flt = OPA->edict != OPB->edict; BREAK + CASE(OP_NE_FNC) OPC->flt = OPA->func != OPB->func; BREAK - case OP_STORE_F: OPB->flt = OPA->flt; break; - case OP_STORE_ENT: OPB->edict = OPA->edict; break; - case OP_STORE_FLD: OPB->field = OPA->field; break; - case OP_STORE_S: OPB->string = OPA->string; break; - case OP_STORE_FNC: OPB->func = OPA->func; break; - case OP_STORE_V: VectorCopy(OPA->vec, OPB->vec); break; + CASE(OP_STORE_F) OPB->flt = OPA->flt; BREAK + CASE(OP_STORE_ENT) OPB->edict = OPA->edict; BREAK + CASE(OP_STORE_FLD) OPB->field = OPA->field; BREAK + CASE(OP_STORE_S) OPB->string = OPA->string; BREAK + CASE(OP_STORE_FNC) OPB->func = OPA->func; BREAK + CASE(OP_STORE_V) VectorCopy(OPA->vec, OPB->vec); BREAK - case OP_STOREP_F: PTR->flt = OPA->flt; break; - case OP_STOREP_ENT: PTR->edict = OPA->edict; break; - case OP_STOREP_FLD: PTR->field = OPA->field; break; - case OP_STOREP_S: PTR->string = OPA->string; break; - case OP_STOREP_FNC: PTR->func = OPA->func; break; - case OP_STOREP_V: VectorCopy(OPA->vec, PTR->vec); break; + CASE(OP_STOREP_F) PTR->flt = OPA->flt; BREAK + CASE(OP_STOREP_ENT) PTR->edict = OPA->edict; BREAK + CASE(OP_STOREP_FLD) PTR->field = OPA->field; BREAK + CASE(OP_STOREP_S) PTR->string = OPA->string; BREAK + CASE(OP_STOREP_FNC) PTR->func = OPA->func; BREAK + CASE(OP_STOREP_V) VectorCopy(OPA->vec, PTR->vec); BREAK - case OP_ADDRESS: - ed = PROG_TO_EDICT(OPA->edict); + CASE(OP_ADDRESS) + ed = EDI; #if defined(PARANOID) - NUM_FOR_EDICT(ed); // Make sure it's in range + NumForEdict(ed); // Make sure it's in range #endif if(ed == (edict_t *)sv.edicts && sv.state == ss_active) { pr_xstatement = st - pr_statements; PR_RunError("assignment to world entity"); } - OPC->field = EDICT_TO_PROG(&ED_PFIELD(ed, OPB->field)); - break; + OPC->field = EdictProg(&ED_PField(ed, OPB->field)); + BREAK - case OP_LOAD_F: - case OP_LOAD_FLD: - case OP_LOAD_ENT: - case OP_LOAD_S: - case OP_LOAD_FNC: - case OP_LOAD_V: - ed = PROG_TO_EDICT(OPA->edict); -#if defined(PARANOID) - NUM_FOR_EDICT(ed); // Make sure it's in range -#endif - switch(st->op) - { - case OP_LOAD_F: OPC->flt = ED_FLOAT(ed, OPB->field); break; - case OP_LOAD_FLD: OPC->field = ED_PFIELD(ed, OPB->field); break; - case OP_LOAD_ENT: OPC->edict = ED_PEDICT(ed, OPB->field); break; - case OP_LOAD_S: OPC->string = ED_RSTRING(ed, OPB->field); break; - case OP_LOAD_FNC: OPC->func = ED_FUNC(ed, OPB->field); break; - case OP_LOAD_V: - VectorCopy(ED_VECTOR(ed, OPB->field), OPC->vec); - break; - } - break; + CASE(OP_LOAD_F) OPC->flt = ED_Float(EDI, OPB->field); BREAK + CASE(OP_LOAD_FLD) OPC->field = ED_PField(EDI, OPB->field); BREAK + CASE(OP_LOAD_ENT) OPC->edict = ED_PEdict(EDI, OPB->field); BREAK + CASE(OP_LOAD_S) OPC->string = ED_RString(EDI, OPB->field); BREAK + CASE(OP_LOAD_FNC) OPC->func = ED_Func(EDI, OPB->field); BREAK + CASE(OP_LOAD_V) VectorCopy(ED_Vector(EDI, OPB->field), OPC->vec); BREAK - case OP_IFNOT: if(!OPA->_int) st += st->b - 1; break; - case OP_IF: if(OPA->_int) st += st->b - 1; break; - case OP_GOTO: st += st->a - 1; break; + CASE(OP_IFNOT) if(!OPA->_int) st += st->b - 1; BREAK + CASE(OP_IF) if(OPA->_int) st += st->b - 1; BREAK + CASE(OP_GOTO) st += st->a - 1; BREAK - case OP_CALL0: - case OP_CALL1: - case OP_CALL2: - case OP_CALL3: - case OP_CALL4: - case OP_CALL5: - case OP_CALL6: - case OP_CALL7: - case OP_CALL8: + CASE(OP_CALL0) + CASE(OP_CALL1) + CASE(OP_CALL2) + CASE(OP_CALL3) + CASE(OP_CALL4) + CASE(OP_CALL5) + CASE(OP_CALL6) + CASE(OP_CALL7) + CASE(OP_CALL8) pr_xfunction->profile += profile - startprofile; startprofile = profile; pr_xstatement = st - pr_statements; @@ -550,38 +470,34 @@ void PR_ExecuteProgram(func_t fnum) // Built-in function int32_t i = -newf->first_statement; if(i >= pr_numbuiltins) - PR_RunError("Bad builtin call number %" PRIi32 "", i); + PR_RunError("Bad builtin call number %" PRIi32, i); pr_builtins[i](); - break; + BREAK } // Normal function st = &pr_statements[PR_EnterFunction(newf)]; - break; + BREAK - case OP_DONE: - case OP_RETURN: + CASE(OP_DONE) + CASE(OP_RETURN) pr_xfunction->profile += profile - startprofile; startprofile = profile; pr_xstatement = st - pr_statements; - G_FLOAT(GBL_RETURN + 0) = G_FLOAT((uint16_t)st->a + 0); - G_FLOAT(GBL_RETURN + 1) = G_FLOAT((uint16_t)st->a + 1); - G_FLOAT(GBL_RETURN + 2) = G_FLOAT((uint16_t)st->a + 2); + G_Float(GBL_RETURN + 0) = G_Float((uint16_t)st->a + 0); + G_Float(GBL_RETURN + 1) = G_Float((uint16_t)st->a + 1); + G_Float(GBL_RETURN + 2) = G_Float((uint16_t)st->a + 2); st = &pr_statements[PR_LeaveFunction()]; if(pr_depth == exitdepth) return; - break; + BREAK - case OP_STATE: - ed = PROG_TO_EDICT(G_PEDICT(GBL_self)); - ED_FLOAT(ed, ED_nextthink) = G_FLOAT(GBL_time) + 0.1; - ED_FLOAT(ed, ED_frame) = OPA->flt; - ED_FUNC(ed, ED_think) = OPB->func; - break; - - default: - pr_xstatement = st - pr_statements; - PR_RunError("Bad opcode %" PRIi32 "", st->op); - } + CASE(OP_STATE) + ed = ProgEdict(G_PEdict(GBL_self)); + ED_Float(ed, ED_nextthink) = G_Float(GBL_time) + 0.1; + ED_Float(ed, ED_frame) = OPA->flt; + ED_Func(ed, ED_think) = OPB->func; + BREAK + END_GOTO_OP } } diff --git a/source/pr_global.h b/source/pr_global.h index 4772d28..bab2472 100644 --- a/source/pr_global.h +++ b/source/pr_global.h @@ -24,18 +24,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef spingle__pr_global_h #define spingle__pr_global_h -#define G_FLOAT(o) (((float *)pr_global_data)[o]) -#define G_INT(o) (((int32_t *)pr_global_data)[o]) -#define G_EDICT(o) PROG_TO_EDICT(G_INT(o)) -#define G_EDICTNUM(o) NUM_FOR_EDICT(G_EDICT(o)) -#define G_VECTOR(o) (&G_FLOAT(o)) -#define G_STRING(o) PR_GetString(G_RSTRING(o)) -#define G_RSTRING(o) (*(string_t *)&G_INT(o)) -#define G_FUNC(o) (*(func_t *)&G_INT(o)) -#define G_PEDICT(o) (*(pedict_t *)&G_INT(o)) -#define G_PFIELD(o) (*(pfield_t *)&G_INT(o)) -#define G_EVAL(o) ((eval_t *)&G_INT(o)) -#define G_VOID(o) ((void *)&G_INT(o)) +#define G_Float(o) (((float *)pr_global_data)[o]) +#define G_Int(o) (((int32_t *)pr_global_data)[o]) +#define G_Edict(o) ProgEdict(G_Int(o)) +#define G_EdictNum(o) NumForEdict(G_Edict(o)) +#define G_Vector(o) (&G_Float(o)) +#define G_String(o) PR_GetString(G_RString(o)) +#define G_RString(o) (*(string_t *)&G_Int(o)) +#define G_Func(o) (*(func_t *)&G_Int(o)) +#define G_PEdict(o) (*(pedict_t *)&G_Int(o)) +#define G_PField(o) (*(pfield_t *)&G_Int(o)) +#define G_Eval(o) ((eval_t *)&G_Int(o)) +#define G_Void(o) ((void *)&G_Int(o)) enum { diff --git a/source/pr_load.c b/source/pr_load.c index 20872f0..b481214 100644 --- a/source/pr_load.c +++ b/source/pr_load.c @@ -94,14 +94,17 @@ static void PR_LoadFunctions(byte const *data) for(i = 0; i < progs.numfunctions; i++) { - pr_functions[i].first_statement = ReadLittleLong(&data); - pr_functions[i].parm_start = ReadLittleLong(&data); - pr_functions[i].locals = ReadLittleLong(&data); - pr_functions[i].profile = 0; ReadSkip(&data, 4); - pr_functions[i].s_name = ReadLittleLong(&data); - pr_functions[i].s_file = ReadLittleLong(&data); - pr_functions[i].numparms = ReadLittleLong(&data); - ReadCopy(pr_functions[i].parm_size, &data, 8); + dfunction_t *fn = &pr_functions[i]; + + fn->first_statement = ReadLittleLong(&data); + fn->parm_start = ReadLittleLong(&data); + fn->locals = ReadLittleLong(&data); + fn->profile = 0; ReadSkip(&data, 4); + fn->s_name = ReadLittleLong(&data); + fn->s_file = ReadLittleLong(&data); + fn->numparms = ReadLittleLong(&data); + + ReadCopy(fn->parm_size, &data, 8); } } @@ -149,13 +152,15 @@ static void PR_LoadFieldDefs(byte const *data) for(i = 0; i < progs.numfielddefs; i++) { - PR_LoadDef(&pr_fielddefs[i], &data); + ddef_t *def = &pr_fielddefs[i]; - if(pr_fielddefs[i].type & DEF_SAVEGLOBAL) + PR_LoadDef(def, &data); + + if(def->type & DEF_SAVEGLOBAL) Host_Error("PR_LoadProgs: field defs cannot have DEF_SAVEGLOBAL"); //johnfitz -- detect alpha support - if(!strcmp(&pr_strings[pr_fielddefs[i].s_name], "alpha")) + if(!strcmp(&pr_strings[def->s_name], "alpha")) pr_alpha_supported = true; //johnfitz } @@ -170,10 +175,15 @@ static void PR_LoadStatements(byte const *data) for(i = 0; i < progs.numstatements; i++) { - pr_statements[i].op = ReadLittleShort(&data); - pr_statements[i].a = ReadLittleShort(&data); - pr_statements[i].b = ReadLittleShort(&data); - pr_statements[i].c = ReadLittleShort(&data); + dstatement_t *st = &pr_statements[i]; + + st->op = ReadLittleShort(&data); + st->a = ReadLittleShort(&data); + st->b = ReadLittleShort(&data); + st->c = ReadLittleShort(&data); + + if(st->op >= OP_MAX) + Host_Error("PR_LoadStatements: bad opcode %" PRIi32, st->op); } } @@ -184,7 +194,7 @@ static void PR_LoadGlobals(byte const *data) pr_global_data = Hunk_Memdup(data, progs.numglobals * 4, "pr_global_data"); for(i = 0; i < progs.numglobals; i++) - G_INT(i) = LittleLong(G_INT(i)); + G_Int(i) = LittleLong(G_Int(i)); } /* diff --git a/source/pr_ops.h b/source/pr_ops.h index 580a303..d294a02 100644 --- a/source/pr_ops.h +++ b/source/pr_ops.h @@ -21,86 +21,94 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef spingle__pr_ops_h +#if defined(pr_ops__xmac) + +pr_ops__xmac(DONE) +pr_ops__xmac(MUL_F) +pr_ops__xmac(MUL_V) +pr_ops__xmac(MUL_FV) +pr_ops__xmac(MUL_VF) +pr_ops__xmac(DIV_F) +pr_ops__xmac(ADD_F) +pr_ops__xmac(ADD_V) +pr_ops__xmac(SUB_F) +pr_ops__xmac(SUB_V) + +pr_ops__xmac(EQ_F) +pr_ops__xmac(EQ_V) +pr_ops__xmac(EQ_S) +pr_ops__xmac(EQ_E) +pr_ops__xmac(EQ_FNC) + +pr_ops__xmac(NE_F) +pr_ops__xmac(NE_V) +pr_ops__xmac(NE_S) +pr_ops__xmac(NE_E) +pr_ops__xmac(NE_FNC) + +pr_ops__xmac(LE) +pr_ops__xmac(GE) +pr_ops__xmac(LT) +pr_ops__xmac(GT) + +pr_ops__xmac(LOAD_F) +pr_ops__xmac(LOAD_V) +pr_ops__xmac(LOAD_S) +pr_ops__xmac(LOAD_ENT) +pr_ops__xmac(LOAD_FLD) +pr_ops__xmac(LOAD_FNC) + +pr_ops__xmac(ADDRESS) + +pr_ops__xmac(STORE_F) +pr_ops__xmac(STORE_V) +pr_ops__xmac(STORE_S) +pr_ops__xmac(STORE_ENT) +pr_ops__xmac(STORE_FLD) +pr_ops__xmac(STORE_FNC) + +pr_ops__xmac(STOREP_F) +pr_ops__xmac(STOREP_V) +pr_ops__xmac(STOREP_S) +pr_ops__xmac(STOREP_ENT) +pr_ops__xmac(STOREP_FLD) +pr_ops__xmac(STOREP_FNC) + +pr_ops__xmac(RETURN) +pr_ops__xmac(NOT_F) +pr_ops__xmac(NOT_V) +pr_ops__xmac(NOT_S) +pr_ops__xmac(NOT_ENT) +pr_ops__xmac(NOT_FNC) +pr_ops__xmac(IF) +pr_ops__xmac(IFNOT) +pr_ops__xmac(CALL0) +pr_ops__xmac(CALL1) +pr_ops__xmac(CALL2) +pr_ops__xmac(CALL3) +pr_ops__xmac(CALL4) +pr_ops__xmac(CALL5) +pr_ops__xmac(CALL6) +pr_ops__xmac(CALL7) +pr_ops__xmac(CALL8) +pr_ops__xmac(STATE) +pr_ops__xmac(GOTO) +pr_ops__xmac(AND) +pr_ops__xmac(OR) + +pr_ops__xmac(BITAND) +pr_ops__xmac(BITOR) + +#undef pr_ops__xmac + +#elif !defined(spingle__pr_ops_h) #define spingle__pr_ops_h enum { - OP_DONE, - OP_MUL_F, - OP_MUL_V, - OP_MUL_FV, - OP_MUL_VF, - OP_DIV_F, - OP_ADD_F, - OP_ADD_V, - OP_SUB_F, - OP_SUB_V, - - OP_EQ_F, - OP_EQ_V, - OP_EQ_S, - OP_EQ_E, - OP_EQ_FNC, - - OP_NE_F, - OP_NE_V, - OP_NE_S, - OP_NE_E, - OP_NE_FNC, - - OP_LE, - OP_GE, - OP_LT, - OP_GT, - - OP_LOAD_F, - OP_LOAD_V, - OP_LOAD_S, - OP_LOAD_ENT, - OP_LOAD_FLD, - OP_LOAD_FNC, - - OP_ADDRESS, - - OP_STORE_F, - OP_STORE_V, - OP_STORE_S, - OP_STORE_ENT, - OP_STORE_FLD, - OP_STORE_FNC, - - OP_STOREP_F, - OP_STOREP_V, - OP_STOREP_S, - OP_STOREP_ENT, - OP_STOREP_FLD, - OP_STOREP_FNC, - - OP_RETURN, - OP_NOT_F, - OP_NOT_V, - OP_NOT_S, - OP_NOT_ENT, - OP_NOT_FNC, - OP_IF, - OP_IFNOT, - OP_CALL0, - OP_CALL1, - OP_CALL2, - OP_CALL3, - OP_CALL4, - OP_CALL5, - OP_CALL6, - OP_CALL7, - OP_CALL8, - OP_STATE, - OP_GOTO, - OP_AND, - OP_OR, - - OP_BITAND, - OP_BITOR +#define pr_ops__xmac(x) OP_##x, +#include "pr_ops.h" + OP_MAX, }; typedef struct diff --git a/source/pr_string.c b/source/pr_string.c index ec6fac8..6e13e26 100644 --- a/source/pr_string.c +++ b/source/pr_string.c @@ -50,7 +50,7 @@ const char *PR_ValueString(int32_t type, eval_t *val) sprintf(line, "%s", PR_GetString(val->string)); break; case ev_entity: - sprintf(line, "entity %" PRIi32 "", NUM_FOR_EDICT(PROG_TO_EDICT(val->edict))); + sprintf(line, "entity %" PRIi32, NumForEdict(ProgEdict(val->edict))); break; case ev_function: f = pr_functions + val->func; @@ -73,7 +73,7 @@ const char *PR_ValueString(int32_t type, eval_t *val) sprintf(line, "pointer"); break; default: - sprintf(line, "bad type %" PRIi32 "", type); + sprintf(line, "bad type %" PRIi32, type); break; } @@ -103,7 +103,7 @@ const char *PR_UglyValueString(int32_t type, eval_t *val) sprintf(line, "%s", PR_GetString(val->string)); break; case ev_entity: - sprintf(line, "%" PRIi32 "", NUM_FOR_EDICT(PROG_TO_EDICT(val->edict))); + sprintf(line, "%" PRIi32, NumForEdict(ProgEdict(val->edict))); break; case ev_function: f = pr_functions + val->func; @@ -123,7 +123,7 @@ const char *PR_UglyValueString(int32_t type, eval_t *val) sprintf(line, "%f %f %f", val->vec[0], val->vec[1], val->vec[2]); break; default: - sprintf(line, "bad type %" PRIi32 "", type); + sprintf(line, "bad type %" PRIi32, type); break; } @@ -147,7 +147,7 @@ const char *PR_GlobalString(int32_t ofs) ddef_t *def; void *val; - val = G_VOID(ofs); + val = G_Void(ofs); def = ED_GlobalAtOfs(ofs); if(!def) sprintf(line, "%" PRIi32 "(?)", ofs); diff --git a/source/protocol.h b/source/protocol.h index 860f6b6..5b0f8b0 100644 --- a/source/protocol.h +++ b/source/protocol.h @@ -60,7 +60,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define U_ALPHA (1<<16) // 1 byte, uses ENTALPHA_ENCODE, not sent if equal to baseline #define U_FRAME2 (1<<17) // 1 byte, this is .frame & 0xFF00 (second byte) #define U_MODEL2 (1<<18) // 1 byte, this is .modelindex & 0xFF00 (second byte) -#define U_LERPFINISH (1<<19) // 1 byte, 0.0-1.0 maps to 0-255, not sent if exactly 0.1, this is ED_FLOAT(ent, ED_nextthink) - sv.time, used for lerping +#define U_LERPFINISH (1<<19) // 1 byte, 0.0-1.0 maps to 0-255, not sent if exactly 0.1, this is ED_Float(ent, ED_nextthink) - sv.time, used for lerping #define U_SCALE (1<<20) // 1 byte, for PROTOCOL_RMQ PRFL_EDICTSCALE, currently read but ignored #define U_UNUSED21 (1<<21) #define U_UNUSED22 (1<<22) diff --git a/source/r_brush.c b/source/r_brush.c index 297884c..8bc41db 100644 --- a/source/r_brush.c +++ b/source/r_brush.c @@ -570,10 +570,9 @@ void GL_BuildLightmaps(void) lightmap_rectchange[i].h = 0; //johnfitz -- use texture manager - sprintf(name, "lightmap%03" PRIi32 "", i); + sprintf(name, "lightmap%03" PRIi32, i); data = lightmaps + i * BLOCK_WIDTH * BLOCK_HEIGHT * lightmap_bytes; - lightmap_textures[i] = TexMgr_LoadImage(cl.worldmodel, name, BLOCK_WIDTH, BLOCK_HEIGHT, - SRC_LIGHTMAP, data, "", (src_offset_t)data, TEXPREF_LINEAR | TEXPREF_NOPICMIP); + lightmap_textures[i] = TexMgr_LoadImage(cl.worldmodel, name, BLOCK_WIDTH, BLOCK_HEIGHT, SRC_LIGHTMAP, data, "", (src_offset_t)data, TEXPREF_LINEAR | TEXPREF_NOPICMIP); //johnfitz } diff --git a/source/sbar.c b/source/sbar.c index 0fa3314..a3d31b0 100644 --- a/source/sbar.c +++ b/source/sbar.c @@ -116,8 +116,8 @@ void Sbar_LoadPics(void) for(i = 0; i < 10; i++) { - sb_nums[0][i] = Draw_PicFromWad(va("num_%" PRIi32 "", i)); - sb_nums[1][i] = Draw_PicFromWad(va("anum_%" PRIi32 "", i)); + sb_nums[0][i] = Draw_PicFromWad(va("num_%" PRIi32, i)); + sb_nums[1][i] = Draw_PicFromWad(va("anum_%" PRIi32, i)); } sb_nums[0][10] = Draw_PicFromWad("num_minus"); @@ -500,17 +500,17 @@ void Sbar_SoloScoreboard(void) int32_t minutes, seconds, tens, units; size_t len; - sprintf(str, "Kills: %" PRIi32 "/%" PRIi32 "", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]); + sprintf(str, "Kills: %" PRIi32 "/%" PRIi32, cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]); Sbar_DrawString(8, 12, str); - sprintf(str, "Secrets: %" PRIi32 "/%" PRIi32 "", cl.stats[STAT_SECRETS], cl.stats[STAT_TOTALSECRETS]); + sprintf(str, "Secrets: %" PRIi32 "/%" PRIi32, cl.stats[STAT_SECRETS], cl.stats[STAT_TOTALSECRETS]); Sbar_DrawString(312 - strlen(str) * 8, 12, str); minutes = cl.time / 60; seconds = cl.time - 60 * minutes; tens = seconds / 10; units = seconds - 10 * tens; - sprintf(str, "%" PRIi32 ":%" PRIi32 "%" PRIi32 "", minutes, tens, units); + sprintf(str, "%" PRIi32 ":%" PRIi32 "%" PRIi32, minutes, tens, units); Sbar_DrawString(160 - strlen(str) * 4, 12, str); len = strlen(cl.levelname); @@ -660,7 +660,7 @@ void Sbar_DrawInventory(void) { val = cl.stats[STAT_SHELLS + i]; val = (val < 0) ? 0 : q_min(999, val); //johnfitz -- cap displayed value to 999 - sprintf(num, "%3" PRIi32 "", val); + sprintf(num, "%3" PRIi32, val); if(num[0] != ' ') Sbar_DrawCharacter((6 * i + 1) * 8 + 2, -24, 18 + num[0] - '0'); if(num[1] != ' ') @@ -796,7 +796,7 @@ void Sbar_DrawFrags(void) Draw_Fill(x + 10, 5, 28, 3, color, 1); // number - sprintf(num, "%3" PRIi32 "", s->frags); + sprintf(num, "%3" PRIi32, s->frags); Sbar_DrawCharacter(x + 12, -24, num[0]); Sbar_DrawCharacter(x + 20, -24, num[1]); Sbar_DrawCharacter(x + 28, -24, num[2]); @@ -849,7 +849,7 @@ void Sbar_DrawFace(void) // draw number f = s->frags; - sprintf(num, "%3" PRIi32 "", f); + sprintf(num, "%3" PRIi32, f); if(top == 8) { @@ -1135,7 +1135,7 @@ void Sbar_DeathmatchOverlay(void) // draw number f = s->frags; - sprintf(num, "%3" PRIi32 "", f); + sprintf(num, "%3" PRIi32, f); Draw_Character(x + 8, y, num[0]); //johnfitz -- stretched overlays Draw_Character(x + 16, y, num[1]); //johnfitz -- stretched overlays @@ -1210,7 +1210,7 @@ void Sbar_MiniDeathmatchOverlay(void) // number f = s->frags; - sprintf(num, "%3" PRIi32 "", f); + sprintf(num, "%3" PRIi32, f); Draw_Character(x + 8, y, num[0]); Draw_Character(x + 16, y, num[1]); Draw_Character(x + 24, y, num[2]); diff --git a/source/sdl/gl_vidsdl.c b/source/sdl/gl_vidsdl.c index 322bdd2..8781db7 100644 --- a/source/sdl/gl_vidsdl.c +++ b/source/sdl/gl_vidsdl.c @@ -1199,7 +1199,7 @@ static void GL_Init(void) gl_version = (const char *) glGetString(GL_VERSION); gl_extensions = (const char *) glGetString(GL_EXTENSIONS); - if(gl_version == NULL || sscanf(gl_version, "%" PRIi32 ".%" PRIi32 "", &gl_version_major, &gl_version_minor) < 2) + if(gl_version == NULL || sscanf(gl_version, "%" PRIi32 ".%" PRIi32, &gl_version_major, &gl_version_minor) < 2) { gl_version_major = 0; gl_version_minor = 0; @@ -1334,7 +1334,7 @@ static void VID_DescribeModes_f(void) { if(count > 0) Con_SafePrintf("\n"); - Con_SafePrintf(" %4" PRIi32 " x %4" PRIi32 " x %" PRIi32 " : %" PRIi32 "", modelist[i].width, modelist[i].height, modelist[i].bpp, modelist[i].refreshrate); + Con_SafePrintf(" %4" PRIi32 " x %4" PRIi32 " x %" PRIi32 " : %" PRIi32, modelist[i].width, modelist[i].height, modelist[i].bpp, modelist[i].refreshrate); lastwidth = modelist[i].width; lastheight = modelist[i].height; lastbpp = modelist[i].bpp; @@ -2087,15 +2087,15 @@ static void VID_MenuDraw(void) { case VID_OPT_MODE: M_Print(16, y, " Video mode"); - M_Print(184, y, va("%" PRIi32 "x%" PRIi32 "", (int32_t)vid_width.value, (int32_t)vid_height.value)); + M_Print(184, y, va("%" PRIi32 "x%" PRIi32, (int32_t)vid_width.value, (int32_t)vid_height.value)); break; case VID_OPT_BPP: M_Print(16, y, " Color depth"); - M_Print(184, y, va("%" PRIi32 "", (int32_t)vid_bpp.value)); + M_Print(184, y, va("%" PRIi32, (int32_t)vid_bpp.value)); break; case VID_OPT_REFRESHRATE: M_Print(16, y, " Refresh rate"); - M_Print(184, y, va("%" PRIi32 "", (int32_t)vid_refreshrate.value)); + M_Print(184, y, va("%" PRIi32, (int32_t)vid_refreshrate.value)); break; case VID_OPT_FULLSCREEN: M_Print(16, y, " Fullscreen"); diff --git a/source/server.h b/source/server.h index d8fd282..9e3f067 100644 --- a/source/server.h +++ b/source/server.h @@ -99,7 +99,7 @@ typedef struct client_s sizebuf_t message; // can be added to at any time, // copied and clear once per frame byte msgbuf[MAX_MSGLEN]; - edict_t *edict; // EDICT_NUM(clientnum+1) + edict_t *edict; // EdictNum(clientnum+1) char name[32]; // for printing to other people int32_t colors; diff --git a/source/snd_dma.c b/source/snd_dma.c index 6733a44..66dbc68 100644 --- a/source/snd_dma.c +++ b/source/snd_dma.c @@ -1033,7 +1033,7 @@ static void S_SoundList(void) Con_SafePrintf(" "); //johnfitz -- was Con_Printf Con_SafePrintf("(%2" PRIi32 "b) %6" PRIi32 " : %s\n", sc->width * 8, size, sfx->name); //johnfitz -- was Con_Printf } - Con_Printf("%" PRIi32" PRIi32 "" sou" PRIi32 "ds, %" PRIi32 " bytes\n", num_sfx, total); //johnfitz -- added count + Con_Printf("%" PRIi32 " sounds, %" PRIi32 " bytes\n", num_sfx, total); //johnfitz -- added count } diff --git a/source/sv_main.c b/source/sv_main.c index 8ec7c80..caf8a36 100644 --- a/source/sv_main.c +++ b/source/sv_main.c @@ -106,7 +106,7 @@ void SV_Init(void) Cmd_AddCommand("sv_protocol", &SV_Protocol_f); //johnfitz for(i = 0 ; i < MAX_MODELS ; i++) - sprintf(localmodels[i], "*%" PRIi32 "", i); + sprintf(localmodels[i], "*%" PRIi32, i); i = COM_CheckParm("-protocol"); if(i && i < com_argc - 1) @@ -189,13 +189,13 @@ void SV_StartSound(edict_t *entity, int32_t channel, const char *sample, int32_t int32_t i, field_mask; if(volume < 0 || volume > 255) - Host_Error("SV_StartSound: volume = %" PRIi32 "", volume); + Host_Error("SV_StartSound: volume = %" PRIi32, volume); if(attenuation < 0 || attenuation > 4) Host_Error("SV_StartSound: attenuation = %f", attenuation); if(channel < 0 || channel > 7) - Host_Error("SV_StartSound: channel = %" PRIi32 "", channel); + Host_Error("SV_StartSound: channel = %" PRIi32, channel); if(sv.datagram.cursize > MAX_DATAGRAM - 16) return; @@ -213,7 +213,7 @@ void SV_StartSound(edict_t *entity, int32_t channel, const char *sample, int32_t return; } - ent = NUM_FOR_EDICT(entity); + ent = NumForEdict(entity); field_mask = 0; if(volume != DEFAULT_SOUND_PACKET_VOLUME) @@ -261,7 +261,7 @@ void SV_StartSound(edict_t *entity, int32_t channel, const char *sample, int32_t //johnfitz for(i = 0; i < 3; i++) - MSG_WriteCoord(&sv.datagram, ED_VECTOR(entity, ED_origin)[i] + 0.5 * (ED_VECTOR(entity, ED_mins)[i] + ED_VECTOR(entity, ED_maxs)[i]), sv.protocolflags); + MSG_WriteCoord(&sv.datagram, ED_Vector(entity, ED_origin)[i] + 0.5 * (ED_Vector(entity, ED_mins)[i] + ED_Vector(entity, ED_maxs)[i]), sv.protocolflags); } /* @@ -306,7 +306,7 @@ void SV_SendServerinfo(client_t *client) else MSG_WriteByte(&client->message, GAME_COOP); - MSG_WriteString(&client->message, ED_STRING(sv.edicts, ED_message)); + MSG_WriteString(&client->message, ED_String(sv.edicts, ED_message)); //johnfitz -- only send the first 256 model and sound precaches if protocol is 15 for(i = 0, s = sv.model_precache + 1 ; *s; s++, i++) @@ -322,12 +322,12 @@ void SV_SendServerinfo(client_t *client) // send music MSG_WriteByte(&client->message, svc_cdtrack); - MSG_WriteByte(&client->message, ED_FLOAT(sv.edicts, ED_sounds)); - MSG_WriteByte(&client->message, ED_FLOAT(sv.edicts, ED_sounds)); + MSG_WriteByte(&client->message, ED_Float(sv.edicts, ED_sounds)); + MSG_WriteByte(&client->message, ED_Float(sv.edicts, ED_sounds)); // set view MSG_WriteByte(&client->message, svc_setview); - MSG_WriteShort(&client->message, NUM_FOR_EDICT(client->edict)); + MSG_WriteShort(&client->message, NumForEdict(client->edict)); MSG_WriteByte(&client->message, svc_signonnum); MSG_WriteByte(&client->message, 1); @@ -359,7 +359,7 @@ void SV_ConnectClient(int32_t clientnum) edictnum = clientnum + 1; - ent = EDICT_NUM(edictnum); + ent = EdictNum(edictnum); // set up the client_t netconnection = client->netconnection; @@ -382,9 +382,9 @@ void SV_ConnectClient(int32_t clientnum) else { // call the progs to get default spawn parms for the new client - PR_ExecuteProgram(G_FUNC(GBL_SetNewParms)); + PR_ExecuteProgram(G_Func(GBL_SetNewParms)); for(i = 0 ; i < NUM_SPAWN_PARMS ; i++) - client->spawn_parms[i] = (&G_FLOAT(GBL_parm1))[i]; + client->spawn_parms[i] = (&G_Float(GBL_parm1))[i]; } SV_SendServerinfo(client); @@ -535,7 +535,7 @@ bool SV_VisibleToClient(edict_t *client, edict_t *test, qmodel_t *worldmodel) vec3_t org; int32_t i; - VectorAdd(ED_VECTOR(client, ED_origin), ED_VECTOR(client, ED_view_ofs), org); + VectorAdd(ED_Vector(client, ED_origin), ED_Vector(client, ED_view_ofs), org); pvs = SV_FatPVS(org, worldmodel); for(i = 0 ; i < test->num_leafs ; i++) @@ -563,22 +563,22 @@ void SV_WriteEntitiesToClient(edict_t *clent, sizebuf_t *msg) edict_t *ent; // find the client's PVS - VectorAdd(ED_VECTOR(clent, ED_origin), ED_VECTOR(clent, ED_view_ofs), org); + VectorAdd(ED_Vector(clent, ED_origin), ED_Vector(clent, ED_view_ofs), org); pvs = SV_FatPVS(org, sv.worldmodel); // send over all entities (excpet the client) that touch the pvs - ent = NEXT_EDICT(sv.edicts); - for(e = 1 ; e < sv.num_edicts ; e++, ent = NEXT_EDICT(ent)) + ent = NextEdict(sv.edicts); + for(e = 1 ; e < sv.num_edicts ; e++, ent = NextEdict(ent)) { if(ent != clent) // clent is ALLWAYS sent { // ignore ents without visible models - if(!ED_FLOAT(ent, ED_modelindex) || !ED_STRING(ent, ED_model)[0]) + if(!ED_Float(ent, ED_modelindex) || !ED_String(ent, ED_model)[0]) continue; //johnfitz -- don't send model>255 entities if protocol is 15 - if(sv.protocol == PROTOCOL_NETQUAKE && (int32_t)ED_FLOAT(ent, ED_modelindex) & 0xFF00) + if(sv.protocol == PROTOCOL_NETQUAKE && (int32_t)ED_Float(ent, ED_modelindex) & 0xFF00) continue; // ignore if not touching a PV leaf @@ -615,36 +615,36 @@ void SV_WriteEntitiesToClient(edict_t *clent, sizebuf_t *msg) for(i = 0 ; i < 3 ; i++) { - miss = ED_VECTOR(ent, ED_origin)[i] - ent->baseline.origin[i]; + miss = ED_Vector(ent, ED_origin)[i] - ent->baseline.origin[i]; if(miss < -0.1 || miss > 0.1) bits |= U_ORIGIN1 << i; } - if(ED_VECTOR(ent, ED_angles)[0] != ent->baseline.angles[0]) + if(ED_Vector(ent, ED_angles)[0] != ent->baseline.angles[0]) bits |= U_ANGLE1; - if(ED_VECTOR(ent, ED_angles)[1] != ent->baseline.angles[1]) + if(ED_Vector(ent, ED_angles)[1] != ent->baseline.angles[1]) bits |= U_ANGLE2; - if(ED_VECTOR(ent, ED_angles)[2] != ent->baseline.angles[2]) + if(ED_Vector(ent, ED_angles)[2] != ent->baseline.angles[2]) bits |= U_ANGLE3; - if(ED_FLOAT(ent, ED_movetype) == MOVETYPE_STEP) + if(ED_Float(ent, ED_movetype) == MOVETYPE_STEP) bits |= U_STEP; // don't mess up the step animation - if(ent->baseline.colormap != ED_FLOAT(ent, ED_colormap)) + if(ent->baseline.colormap != ED_Float(ent, ED_colormap)) bits |= U_COLORMAP; - if(ent->baseline.skin != ED_FLOAT(ent, ED_skin)) + if(ent->baseline.skin != ED_Float(ent, ED_skin)) bits |= U_SKIN; - if(ent->baseline.frame != ED_FLOAT(ent, ED_frame)) + if(ent->baseline.frame != ED_Float(ent, ED_frame)) bits |= U_FRAME; - if(ent->baseline.effects != ED_FLOAT(ent, ED_effects)) + if(ent->baseline.effects != ED_Float(ent, ED_effects)) bits |= U_EFFECTS; - if(ent->baseline.modelindex != ED_FLOAT(ent, ED_modelindex)) + if(ent->baseline.modelindex != ED_Float(ent, ED_modelindex)) bits |= U_MODEL; //johnfitz -- alpha @@ -658,7 +658,7 @@ void SV_WriteEntitiesToClient(edict_t *clent, sizebuf_t *msg) } //don't send invisible entities unless they have effects - if(ent->alpha == ENTALPHA_ZERO && !ED_FLOAT(ent, ED_effects)) + if(ent->alpha == ENTALPHA_ZERO && !ED_Float(ent, ED_effects)) continue; //johnfitz @@ -667,8 +667,8 @@ void SV_WriteEntitiesToClient(edict_t *clent, sizebuf_t *msg) { if(ent->baseline.alpha != ent->alpha) bits |= U_ALPHA; - if(bits & U_FRAME && (int32_t)ED_FLOAT(ent, ED_frame) & 0xFF00) bits |= U_FRAME2; - if(bits & U_MODEL && (int32_t)ED_FLOAT(ent, ED_modelindex) & 0xFF00) bits |= U_MODEL2; + if(bits & U_FRAME && (int32_t)ED_Float(ent, ED_frame) & 0xFF00) bits |= U_FRAME2; + if(bits & U_MODEL && (int32_t)ED_Float(ent, ED_modelindex) & 0xFF00) bits |= U_MODEL2; if(ent->sendinterval) bits |= U_LERPFINISH; if(bits >= 65536) bits |= U_EXTEND1; if(bits >= 16777216) bits |= U_EXTEND2; @@ -702,37 +702,37 @@ void SV_WriteEntitiesToClient(edict_t *clent, sizebuf_t *msg) MSG_WriteByte(msg, e); if(bits & U_MODEL) - MSG_WriteByte(msg, ED_FLOAT(ent, ED_modelindex)); + MSG_WriteByte(msg, ED_Float(ent, ED_modelindex)); if(bits & U_FRAME) - MSG_WriteByte(msg, ED_FLOAT(ent, ED_frame)); + MSG_WriteByte(msg, ED_Float(ent, ED_frame)); if(bits & U_COLORMAP) - MSG_WriteByte(msg, ED_FLOAT(ent, ED_colormap)); + MSG_WriteByte(msg, ED_Float(ent, ED_colormap)); if(bits & U_SKIN) - MSG_WriteByte(msg, ED_FLOAT(ent, ED_skin)); + MSG_WriteByte(msg, ED_Float(ent, ED_skin)); if(bits & U_EFFECTS) - MSG_WriteByte(msg, ED_FLOAT(ent, ED_effects)); + MSG_WriteByte(msg, ED_Float(ent, ED_effects)); if(bits & U_ORIGIN1) - MSG_WriteCoord(msg, ED_VECTOR(ent, ED_origin)[0], sv.protocolflags); + MSG_WriteCoord(msg, ED_Vector(ent, ED_origin)[0], sv.protocolflags); if(bits & U_ANGLE1) - MSG_WriteAngle(msg, ED_VECTOR(ent, ED_angles)[0], sv.protocolflags); + MSG_WriteAngle(msg, ED_Vector(ent, ED_angles)[0], sv.protocolflags); if(bits & U_ORIGIN2) - MSG_WriteCoord(msg, ED_VECTOR(ent, ED_origin)[1], sv.protocolflags); + MSG_WriteCoord(msg, ED_Vector(ent, ED_origin)[1], sv.protocolflags); if(bits & U_ANGLE2) - MSG_WriteAngle(msg, ED_VECTOR(ent, ED_angles)[1], sv.protocolflags); + MSG_WriteAngle(msg, ED_Vector(ent, ED_angles)[1], sv.protocolflags); if(bits & U_ORIGIN3) - MSG_WriteCoord(msg, ED_VECTOR(ent, ED_origin)[2], sv.protocolflags); + MSG_WriteCoord(msg, ED_Vector(ent, ED_origin)[2], sv.protocolflags); if(bits & U_ANGLE3) - MSG_WriteAngle(msg, ED_VECTOR(ent, ED_angles)[2], sv.protocolflags); + MSG_WriteAngle(msg, ED_Vector(ent, ED_angles)[2], sv.protocolflags); //johnfitz -- PROTOCOL_FITZQUAKE if(bits & U_ALPHA) MSG_WriteByte(msg, ent->alpha); if(bits & U_FRAME2) - MSG_WriteByte(msg, (int32_t)ED_FLOAT(ent, ED_frame) >> 8); + MSG_WriteByte(msg, (int32_t)ED_Float(ent, ED_frame) >> 8); if(bits & U_MODEL2) - MSG_WriteByte(msg, (int32_t)ED_FLOAT(ent, ED_modelindex) >> 8); + MSG_WriteByte(msg, (int32_t)ED_Float(ent, ED_modelindex) >> 8); if(bits & U_LERPFINISH) - MSG_WriteByte(msg, (byte)(Q_rint((ED_FLOAT(ent, ED_nextthink) - sv.time) * 255))); + MSG_WriteByte(msg, (byte)(Q_rint((ED_Float(ent, ED_nextthink) - sv.time) * 255))); //johnfitz } @@ -756,10 +756,10 @@ void SV_CleanupEnts(void) int32_t e; edict_t *ent; - ent = NEXT_EDICT(sv.edicts); - for(e = 1 ; e < sv.num_edicts ; e++, ent = NEXT_EDICT(ent)) + ent = NextEdict(sv.edicts); + for(e = 1 ; e < sv.num_edicts ; e++, ent = NextEdict(ent)) { - ED_FLOAT(ent, ED_effects) = (int32_t)ED_FLOAT(ent, ED_effects) & ~EF_MUZZLEFLASH; + ED_Float(ent, ED_effects) = (int32_t)ED_Float(ent, ED_effects) & ~EF_MUZZLEFLASH; } } @@ -780,17 +780,17 @@ void SV_WriteClientdataToMessage(edict_t *ent, sizebuf_t *msg) // // send a damage message // - if(ED_FLOAT(ent, ED_dmg_take) || ED_FLOAT(ent, ED_dmg_save)) + if(ED_Float(ent, ED_dmg_take) || ED_Float(ent, ED_dmg_save)) { - other = PROG_TO_EDICT(ED_PEDICT(ent, ED_dmg_inflictor)); + other = ProgEdict(ED_PEdict(ent, ED_dmg_inflictor)); MSG_WriteByte(msg, svc_damage); - MSG_WriteByte(msg, ED_FLOAT(ent, ED_dmg_save)); - MSG_WriteByte(msg, ED_FLOAT(ent, ED_dmg_take)); + MSG_WriteByte(msg, ED_Float(ent, ED_dmg_save)); + MSG_WriteByte(msg, ED_Float(ent, ED_dmg_take)); for(i = 0 ; i < 3 ; i++) - MSG_WriteCoord(msg, ED_VECTOR(other, ED_origin)[i] + 0.5 * (ED_VECTOR(other, ED_mins)[i] + ED_VECTOR(other, ED_maxs)[i]), sv.protocolflags); + MSG_WriteCoord(msg, ED_Vector(other, ED_origin)[i] + 0.5 * (ED_Vector(other, ED_mins)[i] + ED_Vector(other, ED_maxs)[i]), sv.protocolflags); - ED_FLOAT(ent, ED_dmg_take) = 0; - ED_FLOAT(ent, ED_dmg_save) = 0; + ED_Float(ent, ED_dmg_take) = 0; + ED_Float(ent, ED_dmg_save) = 0; } // @@ -799,20 +799,20 @@ void SV_WriteClientdataToMessage(edict_t *ent, sizebuf_t *msg) SV_SetIdealPitch(); // how much to look up / down ideally // a fixangle might get lost in a dropped packet. Oh well. - if(ED_FLOAT(ent, ED_fixangle)) + if(ED_Float(ent, ED_fixangle)) { MSG_WriteByte(msg, svc_setangle); for(i = 0 ; i < 3 ; i++) - MSG_WriteAngle(msg, ED_VECTOR(ent, ED_angles)[i], sv.protocolflags); - ED_FLOAT(ent, ED_fixangle) = 0; + MSG_WriteAngle(msg, ED_Vector(ent, ED_angles)[i], sv.protocolflags); + ED_Float(ent, ED_fixangle) = 0; } bits = 0; - if(ED_VECTOR(ent, ED_view_ofs)[2] != DEFAULT_VIEWHEIGHT) + if(ED_Vector(ent, ED_view_ofs)[2] != DEFAULT_VIEWHEIGHT) bits |= SU_VIEWHEIGHT; - if(ED_FLOAT(ent, ED_idealpitch)) + if(ED_Float(ent, ED_idealpitch)) bits |= SU_IDEALPITCH; // stuff the sigil bits into the high bits of items for sbar, or else @@ -820,46 +820,46 @@ void SV_WriteClientdataToMessage(edict_t *ent, sizebuf_t *msg) val = GetEdictFieldValue(ent, "items2"); if(val) - items = (int32_t)ED_FLOAT(ent, ED_items) | ((int32_t)val->flt << 23); + items = (int32_t)ED_Float(ent, ED_items) | ((int32_t)val->flt << 23); else - items = (int32_t)ED_FLOAT(ent, ED_items) | ((int32_t)G_FLOAT(GBL_serverflags) << 28); + items = (int32_t)ED_Float(ent, ED_items) | ((int32_t)G_Float(GBL_serverflags) << 28); bits |= SU_ITEMS; - if((int32_t)ED_FLOAT(ent, ED_flags) & FL_ONGROUND) + if((int32_t)ED_Float(ent, ED_flags) & FL_ONGROUND) bits |= SU_ONGROUND; - if(ED_FLOAT(ent, ED_waterlevel) >= 2) + if(ED_Float(ent, ED_waterlevel) >= 2) bits |= SU_INWATER; for(i = 0 ; i < 3 ; i++) { - if(ED_VECTOR(ent, ED_punchangle)[i]) + if(ED_Vector(ent, ED_punchangle)[i]) bits |= (SU_PUNCH1 << i); - if(ED_VECTOR(ent, ED_velocity)[i]) + if(ED_Vector(ent, ED_velocity)[i]) bits |= (SU_VELOCITY1 << i); } - if(ED_FLOAT(ent, ED_weaponframe)) + if(ED_Float(ent, ED_weaponframe)) bits |= SU_WEAPONFRAME; - if(ED_FLOAT(ent, ED_armorvalue)) + if(ED_Float(ent, ED_armorvalue)) bits |= SU_ARMOR; -// if (ED_FLOAT(ent, ED_weapon)) +// if (ED_Float(ent, ED_weapon)) bits |= SU_WEAPON; //johnfitz -- PROTOCOL_FITZQUAKE if(sv.protocol != PROTOCOL_NETQUAKE) { - if(bits & SU_WEAPON && SV_ModelIndex(ED_STRING(ent, ED_weaponmodel)) & 0xFF00) bits |= SU_WEAPON2; - if((int32_t)ED_FLOAT(ent, ED_armorvalue) & 0xFF00) bits |= SU_ARMOR2; - if((int32_t)ED_FLOAT(ent, ED_currentammo) & 0xFF00) bits |= SU_AMMO2; - if((int32_t)ED_FLOAT(ent, ED_ammo_shells) & 0xFF00) bits |= SU_SHELLS2; - if((int32_t)ED_FLOAT(ent, ED_ammo_nails) & 0xFF00) bits |= SU_NAILS2; - if((int32_t)ED_FLOAT(ent, ED_ammo_rockets) & 0xFF00) bits |= SU_ROCKETS2; - if((int32_t)ED_FLOAT(ent, ED_ammo_cells) & 0xFF00) bits |= SU_CELLS2; - if(bits & SU_WEAPONFRAME && (int32_t)ED_FLOAT(ent, ED_weaponframe) & 0xFF00) bits |= SU_WEAPONFRAME2; + if(bits & SU_WEAPON && SV_ModelIndex(ED_String(ent, ED_weaponmodel)) & 0xFF00) bits |= SU_WEAPON2; + if((int32_t)ED_Float(ent, ED_armorvalue) & 0xFF00) bits |= SU_ARMOR2; + if((int32_t)ED_Float(ent, ED_currentammo) & 0xFF00) bits |= SU_AMMO2; + if((int32_t)ED_Float(ent, ED_ammo_shells) & 0xFF00) bits |= SU_SHELLS2; + if((int32_t)ED_Float(ent, ED_ammo_nails) & 0xFF00) bits |= SU_NAILS2; + if((int32_t)ED_Float(ent, ED_ammo_rockets) & 0xFF00) bits |= SU_ROCKETS2; + if((int32_t)ED_Float(ent, ED_ammo_cells) & 0xFF00) bits |= SU_CELLS2; + if(bits & SU_WEAPONFRAME && (int32_t)ED_Float(ent, ED_weaponframe) & 0xFF00) bits |= SU_WEAPONFRAME2; if(bits & SU_WEAPON && ent->alpha != ENTALPHA_DEFAULT) bits |= SU_WEAPONALPHA; //for now, weaponalpha = client entity alpha if(bits >= 65536) bits |= SU_EXTEND1; if(bits >= 16777216) bits |= SU_EXTEND2; @@ -877,45 +877,45 @@ void SV_WriteClientdataToMessage(edict_t *ent, sizebuf_t *msg) //johnfitz if(bits & SU_VIEWHEIGHT) - MSG_WriteChar(msg, ED_VECTOR(ent, ED_view_ofs)[2]); + MSG_WriteChar(msg, ED_Vector(ent, ED_view_ofs)[2]); if(bits & SU_IDEALPITCH) - MSG_WriteChar(msg, ED_FLOAT(ent, ED_idealpitch)); + MSG_WriteChar(msg, ED_Float(ent, ED_idealpitch)); for(i = 0 ; i < 3 ; i++) { if(bits & (SU_PUNCH1 << i)) - MSG_WriteChar(msg, ED_VECTOR(ent, ED_punchangle)[i]); + MSG_WriteChar(msg, ED_Vector(ent, ED_punchangle)[i]); if(bits & (SU_VELOCITY1 << i)) - MSG_WriteChar(msg, ED_VECTOR(ent, ED_velocity)[i] / 16); + MSG_WriteChar(msg, ED_Vector(ent, ED_velocity)[i] / 16); } // [always sent] if (bits & SU_ITEMS) MSG_WriteLong(msg, items); if(bits & SU_WEAPONFRAME) - MSG_WriteByte(msg, ED_FLOAT(ent, ED_weaponframe)); + MSG_WriteByte(msg, ED_Float(ent, ED_weaponframe)); if(bits & SU_ARMOR) - MSG_WriteByte(msg, ED_FLOAT(ent, ED_armorvalue)); + MSG_WriteByte(msg, ED_Float(ent, ED_armorvalue)); if(bits & SU_WEAPON) - MSG_WriteByte(msg, SV_ModelIndex(ED_STRING(ent, ED_weaponmodel))); + MSG_WriteByte(msg, SV_ModelIndex(ED_String(ent, ED_weaponmodel))); - MSG_WriteShort(msg, ED_FLOAT(ent, ED_health)); - MSG_WriteByte(msg, ED_FLOAT(ent, ED_currentammo)); - MSG_WriteByte(msg, ED_FLOAT(ent, ED_ammo_shells)); - MSG_WriteByte(msg, ED_FLOAT(ent, ED_ammo_nails)); - MSG_WriteByte(msg, ED_FLOAT(ent, ED_ammo_rockets)); - MSG_WriteByte(msg, ED_FLOAT(ent, ED_ammo_cells)); + MSG_WriteShort(msg, ED_Float(ent, ED_health)); + MSG_WriteByte(msg, ED_Float(ent, ED_currentammo)); + MSG_WriteByte(msg, ED_Float(ent, ED_ammo_shells)); + MSG_WriteByte(msg, ED_Float(ent, ED_ammo_nails)); + MSG_WriteByte(msg, ED_Float(ent, ED_ammo_rockets)); + MSG_WriteByte(msg, ED_Float(ent, ED_ammo_cells)); if(standard_quake) { - MSG_WriteByte(msg, ED_FLOAT(ent, ED_weapon)); + MSG_WriteByte(msg, ED_Float(ent, ED_weapon)); } else { for(i = 0; i < 32; i++) { - if(((int32_t)ED_FLOAT(ent, ED_weapon)) & (1 << i)) + if(((int32_t)ED_Float(ent, ED_weapon)) & (1 << i)) { MSG_WriteByte(msg, i); break; @@ -925,21 +925,21 @@ void SV_WriteClientdataToMessage(edict_t *ent, sizebuf_t *msg) //johnfitz -- PROTOCOL_FITZQUAKE if(bits & SU_WEAPON2) - MSG_WriteByte(msg, SV_ModelIndex(ED_STRING(ent, ED_weaponmodel)) >> 8); + MSG_WriteByte(msg, SV_ModelIndex(ED_String(ent, ED_weaponmodel)) >> 8); if(bits & SU_ARMOR2) - MSG_WriteByte(msg, (int32_t)ED_FLOAT(ent, ED_armorvalue) >> 8); + MSG_WriteByte(msg, (int32_t)ED_Float(ent, ED_armorvalue) >> 8); if(bits & SU_AMMO2) - MSG_WriteByte(msg, (int32_t)ED_FLOAT(ent, ED_currentammo) >> 8); + MSG_WriteByte(msg, (int32_t)ED_Float(ent, ED_currentammo) >> 8); if(bits & SU_SHELLS2) - MSG_WriteByte(msg, (int32_t)ED_FLOAT(ent, ED_ammo_shells) >> 8); + MSG_WriteByte(msg, (int32_t)ED_Float(ent, ED_ammo_shells) >> 8); if(bits & SU_NAILS2) - MSG_WriteByte(msg, (int32_t)ED_FLOAT(ent, ED_ammo_nails) >> 8); + MSG_WriteByte(msg, (int32_t)ED_Float(ent, ED_ammo_nails) >> 8); if(bits & SU_ROCKETS2) - MSG_WriteByte(msg, (int32_t)ED_FLOAT(ent, ED_ammo_rockets) >> 8); + MSG_WriteByte(msg, (int32_t)ED_Float(ent, ED_ammo_rockets) >> 8); if(bits & SU_CELLS2) - MSG_WriteByte(msg, (int32_t)ED_FLOAT(ent, ED_ammo_cells) >> 8); + MSG_WriteByte(msg, (int32_t)ED_Float(ent, ED_ammo_cells) >> 8); if(bits & SU_WEAPONFRAME2) - MSG_WriteByte(msg, (int32_t)ED_FLOAT(ent, ED_weaponframe) >> 8); + MSG_WriteByte(msg, (int32_t)ED_Float(ent, ED_weaponframe) >> 8); if(bits & SU_WEAPONALPHA) MSG_WriteByte(msg, ent->alpha); //for now, weaponalpha = client entity alpha //johnfitz @@ -999,7 +999,7 @@ void SV_UpdateToReliableMessages(void) // check for changes to be sent over the reliable streams for(i = 0, host_client = svs.clients ; i < svs.maxclients ; i++, host_client++) { - if(host_client->old_frags != ED_FLOAT(host_client->edict, ED_frags)) + if(host_client->old_frags != ED_Float(host_client->edict, ED_frags)) { for(j = 0, client = svs.clients ; j < svs.maxclients ; j++, client++) { @@ -1007,10 +1007,10 @@ void SV_UpdateToReliableMessages(void) continue; MSG_WriteByte(&client->message, svc_updatefrags); MSG_WriteByte(&client->message, i); - MSG_WriteShort(&client->message, ED_FLOAT(host_client->edict, ED_frags)); + MSG_WriteShort(&client->message, ED_Float(host_client->edict, ED_frags)); } - host_client->old_frags = ED_FLOAT(host_client->edict, ED_frags); + host_client->old_frags = ED_Float(host_client->edict, ED_frags); } } @@ -1169,19 +1169,19 @@ void SV_CreateBaseline(void) for(entnum = 0; entnum < sv.num_edicts ; entnum++) { // get the current server version - svent = EDICT_NUM(entnum); + svent = EdictNum(entnum); if(svent->free) continue; - if(entnum > svs.maxclients && !ED_FLOAT(svent, ED_modelindex)) + if(entnum > svs.maxclients && !ED_Float(svent, ED_modelindex)) continue; // // create entity baseline // - VectorCopy(ED_VECTOR(svent, ED_origin), svent->baseline.origin); - VectorCopy(ED_VECTOR(svent, ED_angles), svent->baseline.angles); - svent->baseline.frame = ED_FLOAT(svent, ED_frame); - svent->baseline.skin = ED_FLOAT(svent, ED_skin); + VectorCopy(ED_Vector(svent, ED_origin), svent->baseline.origin); + VectorCopy(ED_Vector(svent, ED_angles), svent->baseline.angles); + svent->baseline.frame = ED_Float(svent, ED_frame); + svent->baseline.skin = ED_Float(svent, ED_skin); if(entnum > 0 && entnum <= svs.maxclients) { svent->baseline.colormap = entnum; @@ -1191,7 +1191,7 @@ void SV_CreateBaseline(void) else { svent->baseline.colormap = 0; - svent->baseline.modelindex = SV_ModelIndex(ED_STRING(svent, ED_model)); + svent->baseline.modelindex = SV_ModelIndex(ED_String(svent, ED_model)); svent->baseline.alpha = svent->alpha; //johnfitz -- alpha support } @@ -1296,7 +1296,7 @@ void SV_SaveSpawnparms(void) { int32_t i, j; - svs.serverflags = G_FLOAT(GBL_serverflags); + svs.serverflags = G_Float(GBL_serverflags); for(i = 0, host_client = svs.clients ; i < svs.maxclients ; i++, host_client++) { @@ -1304,10 +1304,10 @@ void SV_SaveSpawnparms(void) continue; // call the progs to get default spawn parms for the new client - G_PEDICT(GBL_self) = EDICT_TO_PROG(host_client->edict); - PR_ExecuteProgram(G_FUNC(GBL_SetChangeParms)); + G_PEdict(GBL_self) = EdictProg(host_client->edict); + PR_ExecuteProgram(G_Func(GBL_SetChangeParms)); for(j = 0 ; j < NUM_SPAWN_PARMS ; j++) - host_client->spawn_parms[j] = (&G_FLOAT(GBL_parm1))[j]; + host_client->spawn_parms[j] = (&G_Float(GBL_parm1))[j]; } } @@ -1398,7 +1398,7 @@ void SV_SpawnServer(const char *server) memset(sv.edicts, 0, sv.num_edicts * pr_edict_size); // ericw -- sv.edicts switched to use malloc() for(i = 0 ; i < svs.maxclients ; i++) { - ent = EDICT_NUM(i + 1); + ent = EdictNum(i + 1); svs.clients[i].edict = ent; } @@ -1435,23 +1435,23 @@ void SV_SpawnServer(const char *server) // // load the rest of the entities // - ent = EDICT_NUM(0); + ent = EdictNum(0); memset(ent->fields, 0, progs.entityfields * 4); ent->free = false; - ED_RSTRING(ent, ED_model) = PR_SetEngineString(sv.worldmodel->name); - ED_FLOAT(ent, ED_modelindex) = 1; // world model - ED_FLOAT(ent, ED_solid) = SOLID_BSP; - ED_FLOAT(ent, ED_movetype) = MOVETYPE_PUSH; + ED_RString(ent, ED_model) = PR_SetEngineString(sv.worldmodel->name); + ED_Float(ent, ED_modelindex) = 1; // world model + ED_Float(ent, ED_solid) = SOLID_BSP; + ED_Float(ent, ED_movetype) = MOVETYPE_PUSH; if(coop.value) - G_FLOAT(GBL_coop) = coop.value; + G_Float(GBL_coop) = coop.value; else - G_FLOAT(GBL_deathmatch) = deathmatch.value; + G_Float(GBL_deathmatch) = deathmatch.value; - G_RSTRING(GBL_mapname) = PR_SetEngineString(sv.name); + G_RString(GBL_mapname) = PR_SetEngineString(sv.name); // serverflags are for cross level information (sigils) - G_FLOAT(GBL_serverflags) = svs.serverflags; + G_Float(GBL_serverflags) = svs.serverflags; ED_LoadFromFile(sv.worldmodel->entities); diff --git a/source/sv_move.c b/source/sv_move.c index c43546c..773f9bf 100644 --- a/source/sv_move.c +++ b/source/sv_move.c @@ -43,8 +43,8 @@ bool SV_CheckBottom(edict_t *ent) int32_t x, y; float mid, bottom; - VectorAdd(ED_VECTOR(ent, ED_origin), ED_VECTOR(ent, ED_mins), mins); - VectorAdd(ED_VECTOR(ent, ED_origin), ED_VECTOR(ent, ED_maxs), maxs); + VectorAdd(ED_Vector(ent, ED_origin), ED_Vector(ent, ED_mins), mins); + VectorAdd(ED_Vector(ent, ED_origin), ED_Vector(ent, ED_maxs), maxs); // if all of the points under the corners are solid world, don't bother // with the tougher checks @@ -118,33 +118,33 @@ bool SV_movestep(edict_t *ent, vec3_t move, bool relink) edict_t *enemy; // try the move - VectorCopy(ED_VECTOR(ent, ED_origin), oldorg); - VectorAdd(ED_VECTOR(ent, ED_origin), move, neworg); + VectorCopy(ED_Vector(ent, ED_origin), oldorg); + VectorAdd(ED_Vector(ent, ED_origin), move, neworg); // flying monsters don't step up - if((int32_t)ED_FLOAT(ent, ED_flags) & (FL_SWIM | FL_FLY)) + if((int32_t)ED_Float(ent, ED_flags) & (FL_SWIM | FL_FLY)) { // try one move with vertical motion, then one without for(i = 0 ; i < 2 ; i++) { - VectorAdd(ED_VECTOR(ent, ED_origin), move, neworg); - enemy = PROG_TO_EDICT(ED_PEDICT(ent, ED_enemy)); + VectorAdd(ED_Vector(ent, ED_origin), move, neworg); + enemy = ProgEdict(ED_PEdict(ent, ED_enemy)); if(i == 0 && enemy != sv.edicts) { - dz = ED_VECTOR(ent, ED_origin)[2] - ED_VECTOR(PROG_TO_EDICT(ED_PEDICT(ent, ED_enemy)), ED_origin)[2]; + dz = ED_Vector(ent, ED_origin)[2] - ED_Vector(ProgEdict(ED_PEdict(ent, ED_enemy)), ED_origin)[2]; if(dz > 40) neworg[2] -= 8; if(dz < 30) neworg[2] += 8; } - trace = SV_Move(ED_VECTOR(ent, ED_origin), ED_VECTOR(ent, ED_mins), ED_VECTOR(ent, ED_maxs), neworg, false, ent); + trace = SV_Move(ED_Vector(ent, ED_origin), ED_Vector(ent, ED_mins), ED_Vector(ent, ED_maxs), neworg, false, ent); if(trace.fraction == 1) { - if(((int32_t)ED_FLOAT(ent, ED_flags) & FL_SWIM) && SV_PointContents(trace.endpos) == CONTENTS_EMPTY) + if(((int32_t)ED_Float(ent, ED_flags) & FL_SWIM) && SV_PointContents(trace.endpos) == CONTENTS_EMPTY) return false; // swim monster left water - VectorCopy(trace.endpos, ED_VECTOR(ent, ED_origin)); + VectorCopy(trace.endpos, ED_Vector(ent, ED_origin)); if(relink) SV_LinkEdict(ent, true); return true; @@ -162,7 +162,7 @@ bool SV_movestep(edict_t *ent, vec3_t move, bool relink) VectorCopy(neworg, end); end[2] -= STEPSIZE * 2; - trace = SV_Move(neworg, ED_VECTOR(ent, ED_mins), ED_VECTOR(ent, ED_maxs), end, false, ent); + trace = SV_Move(neworg, ED_Vector(ent, ED_mins), ED_Vector(ent, ED_maxs), end, false, ent); if(trace.allsolid) return false; @@ -170,19 +170,19 @@ bool SV_movestep(edict_t *ent, vec3_t move, bool relink) if(trace.startsolid) { neworg[2] -= STEPSIZE; - trace = SV_Move(neworg, ED_VECTOR(ent, ED_mins), ED_VECTOR(ent, ED_maxs), end, false, ent); + trace = SV_Move(neworg, ED_Vector(ent, ED_mins), ED_Vector(ent, ED_maxs), end, false, ent); if(trace.allsolid || trace.startsolid) return false; } if(trace.fraction == 1) { // if monster had the ground pulled out, go ahead and fall - if((int32_t)ED_FLOAT(ent, ED_flags) & FL_PARTIALGROUND) + if((int32_t)ED_Float(ent, ED_flags) & FL_PARTIALGROUND) { - VectorAdd(ED_VECTOR(ent, ED_origin), move, ED_VECTOR(ent, ED_origin)); + VectorAdd(ED_Vector(ent, ED_origin), move, ED_Vector(ent, ED_origin)); if(relink) SV_LinkEdict(ent, true); - ED_FLOAT(ent, ED_flags) = (int32_t)ED_FLOAT(ent, ED_flags) & ~FL_ONGROUND; + ED_Float(ent, ED_flags) = (int32_t)ED_Float(ent, ED_flags) & ~FL_ONGROUND; // Con_Printf ("fall down\n"); return true; } @@ -191,11 +191,11 @@ bool SV_movestep(edict_t *ent, vec3_t move, bool relink) } // check point traces down for dangling corners - VectorCopy(trace.endpos, ED_VECTOR(ent, ED_origin)); + VectorCopy(trace.endpos, ED_Vector(ent, ED_origin)); if(!SV_CheckBottom(ent)) { - if((int32_t)ED_FLOAT(ent, ED_flags) & FL_PARTIALGROUND) + if((int32_t)ED_Float(ent, ED_flags) & FL_PARTIALGROUND) { // entity had floor mostly pulled out from underneath it // and is trying to correct @@ -203,16 +203,16 @@ bool SV_movestep(edict_t *ent, vec3_t move, bool relink) SV_LinkEdict(ent, true); return true; } - VectorCopy(oldorg, ED_VECTOR(ent, ED_origin)); + VectorCopy(oldorg, ED_Vector(ent, ED_origin)); return false; } - if((int32_t)ED_FLOAT(ent, ED_flags) & FL_PARTIALGROUND) + if((int32_t)ED_Float(ent, ED_flags) & FL_PARTIALGROUND) { // Con_Printf ("back on ground\n"); - ED_FLOAT(ent, ED_flags) = (int32_t)ED_FLOAT(ent, ED_flags) & ~FL_PARTIALGROUND; + ED_Float(ent, ED_flags) = (int32_t)ED_Float(ent, ED_flags) & ~FL_PARTIALGROUND; } - ED_PEDICT(ent, ED_groundentity) = EDICT_TO_PROG(trace.ent); + ED_PEdict(ent, ED_groundentity) = EdictProg(trace.ent); // the move is ok if(relink) @@ -238,7 +238,7 @@ bool SV_StepDirection(edict_t *ent, float yaw, float dist) vec3_t move, oldorigin; float delta; - ED_FLOAT(ent, ED_ideal_yaw) = yaw; + ED_Float(ent, ED_ideal_yaw) = yaw; PF_changeyaw(); yaw = yaw * PI * 2 / 360; @@ -246,14 +246,14 @@ bool SV_StepDirection(edict_t *ent, float yaw, float dist) move[1] = sin(yaw) * dist; move[2] = 0; - VectorCopy(ED_VECTOR(ent, ED_origin), oldorigin); + VectorCopy(ED_Vector(ent, ED_origin), oldorigin); if(SV_movestep(ent, move, false)) { - delta = ED_VECTOR(ent, ED_angles)[YAW] - ED_FLOAT(ent, ED_ideal_yaw); + delta = ED_Vector(ent, ED_angles)[YAW] - ED_Float(ent, ED_ideal_yaw); if(delta > 45 && delta < 315) { // not turned far enough, so don't take the step - VectorCopy(oldorigin, ED_VECTOR(ent, ED_origin)); + VectorCopy(oldorigin, ED_Vector(ent, ED_origin)); } SV_LinkEdict(ent, true); return true; @@ -273,7 +273,7 @@ void SV_FixCheckBottom(edict_t *ent) { // Con_Printf ("SV_FixCheckBottom\n"); - ED_FLOAT(ent, ED_flags) = (int32_t)ED_FLOAT(ent, ED_flags) | FL_PARTIALGROUND; + ED_Float(ent, ED_flags) = (int32_t)ED_Float(ent, ED_flags) | FL_PARTIALGROUND; } @@ -291,11 +291,11 @@ void SV_NewChaseDir(edict_t *actor, edict_t *enemy, float dist) float d[3]; float tdir, olddir, turnaround; - olddir = anglemod((int32_t)(ED_FLOAT(actor, ED_ideal_yaw) / 45) * 45); + olddir = anglemod((int32_t)(ED_Float(actor, ED_ideal_yaw) / 45) * 45); turnaround = anglemod(olddir - 180); - deltax = ED_VECTOR(enemy, ED_origin)[0] - ED_VECTOR(actor, ED_origin)[0]; - deltay = ED_VECTOR(enemy, ED_origin)[1] - ED_VECTOR(actor, ED_origin)[1]; + deltax = ED_Vector(enemy, ED_origin)[0] - ED_Vector(actor, ED_origin)[0]; + deltay = ED_Vector(enemy, ED_origin)[1] - ED_Vector(actor, ED_origin)[1]; if(deltax > 10) d[1] = 0; else if(deltax < -10) @@ -358,7 +358,7 @@ void SV_NewChaseDir(edict_t *actor, edict_t *enemy, float dist) if(turnaround != DI_NODIR && SV_StepDirection(actor, turnaround, dist)) return; - ED_FLOAT(actor, ED_ideal_yaw) = olddir; // can't move + ED_Float(actor, ED_ideal_yaw) = olddir; // can't move // if a bridge was pulled out from underneath a monster, it may not have // a valid standing position at all @@ -380,9 +380,9 @@ bool SV_CloseEnough(edict_t *ent, edict_t *goal, float dist) for(i = 0 ; i < 3 ; i++) { - if(ED_VECTOR(goal, ED_absmin)[i] > ED_VECTOR(ent, ED_absmax)[i] + dist) + if(ED_Vector(goal, ED_absmin)[i] > ED_Vector(ent, ED_absmax)[i] + dist) return false; - if(ED_VECTOR(goal, ED_absmax)[i] < ED_VECTOR(ent, ED_absmin)[i] - dist) + if(ED_Vector(goal, ED_absmax)[i] < ED_Vector(ent, ED_absmin)[i] - dist) return false; } return true; @@ -399,23 +399,23 @@ void SV_MoveToGoal(void) edict_t *ent, *goal; float dist; - ent = PROG_TO_EDICT(G_PEDICT(GBL_self)); - goal = PROG_TO_EDICT(ED_PEDICT(ent, ED_goalentity)); - dist = G_FLOAT(GBL_PARM0); + ent = ProgEdict(G_PEdict(GBL_self)); + goal = ProgEdict(ED_PEdict(ent, ED_goalentity)); + dist = G_Float(GBL_PARM0); - if(!((int32_t)ED_FLOAT(ent, ED_flags) & (FL_ONGROUND | FL_FLY | FL_SWIM))) + if(!((int32_t)ED_Float(ent, ED_flags) & (FL_ONGROUND | FL_FLY | FL_SWIM))) { - G_FLOAT(GBL_RETURN) = 0; + G_Float(GBL_RETURN) = 0; return; } // if the next step hits the enemy, return immediately - if(PROG_TO_EDICT(ED_PEDICT(ent, ED_enemy)) != sv.edicts && SV_CloseEnough(ent, goal, dist)) + if(ProgEdict(ED_PEdict(ent, ED_enemy)) != sv.edicts && SV_CloseEnough(ent, goal, dist)) return; // bump around... if((rand() & 3) == 1 || - !SV_StepDirection(ent, ED_FLOAT(ent, ED_ideal_yaw), dist)) + !SV_StepDirection(ent, ED_Float(ent, ED_ideal_yaw), dist)) { SV_NewChaseDir(ent, goal, dist); } diff --git a/source/sv_phys.c b/source/sv_phys.c index f1354c3..01748c9 100644 --- a/source/sv_phys.c +++ b/source/sv_phys.c @@ -64,14 +64,14 @@ void SV_CheckAllEnts(void) edict_t *check; // see if any solid entities are inside the final position - check = NEXT_EDICT(sv.edicts); - for(e = 1 ; e < sv.num_edicts ; e++, check = NEXT_EDICT(check)) + check = NextEdict(sv.edicts); + for(e = 1 ; e < sv.num_edicts ; e++, check = NextEdict(check)) { if(check->free) continue; - if(ED_FLOAT(check, ED_movetype) == MOVETYPE_PUSH - || ED_FLOAT(check, ED_movetype) == MOVETYPE_NONE - || ED_FLOAT(check, ED_movetype) == MOVETYPE_NOCLIP) + if(ED_Float(check, ED_movetype) == MOVETYPE_PUSH + || ED_Float(check, ED_movetype) == MOVETYPE_NONE + || ED_Float(check, ED_movetype) == MOVETYPE_NOCLIP) continue; if(SV_TestEntityPosition(check)) @@ -93,20 +93,20 @@ void SV_CheckVelocity(edict_t *ent) // for(i = 0 ; i < 3 ; i++) { - if(isnan(ED_VECTOR(ent, ED_velocity)[i])) + if(isnan(ED_Vector(ent, ED_velocity)[i])) { - Con_Printf("Got a NaN velocity on %s\n", ED_STRING(ent, ED_classname)); - ED_VECTOR(ent, ED_velocity)[i] = 0; + Con_Printf("Got a NaN velocity on %s\n", ED_String(ent, ED_classname)); + ED_Vector(ent, ED_velocity)[i] = 0; } - if(isnan(ED_VECTOR(ent, ED_origin)[i])) + if(isnan(ED_Vector(ent, ED_origin)[i])) { - Con_Printf("Got a NaN origin on %s\n", ED_STRING(ent, ED_classname)); - ED_VECTOR(ent, ED_origin)[i] = 0; + Con_Printf("Got a NaN origin on %s\n", ED_String(ent, ED_classname)); + ED_Vector(ent, ED_origin)[i] = 0; } - if(ED_VECTOR(ent, ED_velocity)[i] > sv_maxvelocity.value) - ED_VECTOR(ent, ED_velocity)[i] = sv_maxvelocity.value; - else if(ED_VECTOR(ent, ED_velocity)[i] < -sv_maxvelocity.value) - ED_VECTOR(ent, ED_velocity)[i] = -sv_maxvelocity.value; + if(ED_Vector(ent, ED_velocity)[i] > sv_maxvelocity.value) + ED_Vector(ent, ED_velocity)[i] = sv_maxvelocity.value; + else if(ED_Vector(ent, ED_velocity)[i] < -sv_maxvelocity.value) + ED_Vector(ent, ED_velocity)[i] = -sv_maxvelocity.value; } } @@ -126,7 +126,7 @@ bool SV_RunThink(edict_t *ent) float oldframe; //johnfitz int32_t i; //johnfitz - thinktime = ED_FLOAT(ent, ED_nextthink); + thinktime = ED_Float(ent, ED_nextthink); if(thinktime <= 0 || thinktime > sv.time + host_frametime) return true; @@ -135,21 +135,21 @@ bool SV_RunThink(edict_t *ent) // it is possible to start that way // by a trigger with a local time. - oldframe = ED_FLOAT(ent, ED_frame); //johnfitz + oldframe = ED_Float(ent, ED_frame); //johnfitz - ED_FLOAT(ent, ED_nextthink) = 0; - G_FLOAT(GBL_time) = thinktime; - G_PEDICT(GBL_self) = EDICT_TO_PROG(ent); - G_PEDICT(GBL_other) = EDICT_TO_PROG(sv.edicts); - PR_ExecuteProgram(ED_FUNC(ent, ED_think)); + ED_Float(ent, ED_nextthink) = 0; + G_Float(GBL_time) = thinktime; + G_PEdict(GBL_self) = EdictProg(ent); + G_PEdict(GBL_other) = EdictProg(sv.edicts); + PR_ExecuteProgram(ED_Func(ent, ED_think)); //johnfitz -- PROTOCOL_FITZQUAKE //capture interval to nextthink here and send it to client for better //lerp timing, but only if interval is not 0.1 (which client assumes) ent->sendinterval = false; - if(!ent->free && ED_FLOAT(ent, ED_nextthink) && (ED_FLOAT(ent, ED_movetype) == MOVETYPE_STEP || ED_FLOAT(ent, ED_frame) != oldframe)) + if(!ent->free && ED_Float(ent, ED_nextthink) && (ED_Float(ent, ED_movetype) == MOVETYPE_STEP || ED_Float(ent, ED_frame) != oldframe)) { - i = Q_rint((ED_FLOAT(ent, ED_nextthink) - thinktime) * 255); + i = Q_rint((ED_Float(ent, ED_nextthink) - thinktime) * 255); if(i >= 0 && i < 256 && i != 25 && i != 26) //25 and 26 are close enough to 0.1 to not send ent->sendinterval = true; } @@ -169,26 +169,26 @@ void SV_Impact(edict_t *e1, edict_t *e2) { pedict_t old_self, old_other; - old_self = G_PEDICT(GBL_self); - old_other = G_PEDICT(GBL_other); + old_self = G_PEdict(GBL_self); + old_other = G_PEdict(GBL_other); - G_FLOAT(GBL_time) = sv.time; - if(ED_FUNC(e1, ED_touch) && ED_FLOAT(e1, ED_solid) != SOLID_NOT) + G_Float(GBL_time) = sv.time; + if(ED_Func(e1, ED_touch) && ED_Float(e1, ED_solid) != SOLID_NOT) { - G_PEDICT(GBL_self) = EDICT_TO_PROG(e1); - G_PEDICT(GBL_other) = EDICT_TO_PROG(e2); - PR_ExecuteProgram(ED_FUNC(e1, ED_touch)); + G_PEdict(GBL_self) = EdictProg(e1); + G_PEdict(GBL_other) = EdictProg(e2); + PR_ExecuteProgram(ED_Func(e1, ED_touch)); } - if(ED_FUNC(e2, ED_touch) && ED_FLOAT(e2, ED_solid) != SOLID_NOT) + if(ED_Func(e2, ED_touch) && ED_Float(e2, ED_solid) != SOLID_NOT) { - G_PEDICT(GBL_self) = EDICT_TO_PROG(e2); - G_PEDICT(GBL_other) = EDICT_TO_PROG(e1); - PR_ExecuteProgram(ED_FUNC(e2, ED_touch)); + G_PEdict(GBL_self) = EdictProg(e2); + G_PEdict(GBL_other) = EdictProg(e1); + PR_ExecuteProgram(ED_Func(e2, ED_touch)); } - G_PEDICT(GBL_self) = old_self; - G_PEDICT(GBL_other) = old_other; + G_PEdict(GBL_self) = old_self; + G_PEdict(GBL_other) = old_other; } @@ -258,34 +258,34 @@ int32_t SV_FlyMove(edict_t *ent, float time, trace_t *steptrace) numbumps = 4; blocked = 0; - VectorCopy(ED_VECTOR(ent, ED_velocity), original_velocity); - VectorCopy(ED_VECTOR(ent, ED_velocity), primal_velocity); + VectorCopy(ED_Vector(ent, ED_velocity), original_velocity); + VectorCopy(ED_Vector(ent, ED_velocity), primal_velocity); numplanes = 0; time_left = time; for(bumpcount = 0 ; bumpcount < numbumps ; bumpcount++) { - if(!ED_VECTOR(ent, ED_velocity)[0] && !ED_VECTOR(ent, ED_velocity)[1] && !ED_VECTOR(ent, ED_velocity)[2]) + if(!ED_Vector(ent, ED_velocity)[0] && !ED_Vector(ent, ED_velocity)[1] && !ED_Vector(ent, ED_velocity)[2]) break; for(i = 0 ; i < 3 ; i++) - end[i] = ED_VECTOR(ent, ED_origin)[i] + time_left * ED_VECTOR(ent, ED_velocity)[i]; + end[i] = ED_Vector(ent, ED_origin)[i] + time_left * ED_Vector(ent, ED_velocity)[i]; - trace = SV_Move(ED_VECTOR(ent, ED_origin), ED_VECTOR(ent, ED_mins), ED_VECTOR(ent, ED_maxs), end, false, ent); + trace = SV_Move(ED_Vector(ent, ED_origin), ED_Vector(ent, ED_mins), ED_Vector(ent, ED_maxs), end, false, ent); if(trace.allsolid) { // entity is trapped in another solid - VectorCopy(vec3_origin, ED_VECTOR(ent, ED_velocity)); + VectorCopy(vec3_origin, ED_Vector(ent, ED_velocity)); return 3; } if(trace.fraction > 0) { // actually covered some distance - VectorCopy(trace.endpos, ED_VECTOR(ent, ED_origin)); - VectorCopy(ED_VECTOR(ent, ED_velocity), original_velocity); + VectorCopy(trace.endpos, ED_Vector(ent, ED_origin)); + VectorCopy(ED_Vector(ent, ED_velocity), original_velocity); numplanes = 0; } @@ -298,10 +298,10 @@ int32_t SV_FlyMove(edict_t *ent, float time, trace_t *steptrace) if(trace.plane.normal[2] > 0.7) { blocked |= 1; // floor - if(ED_FLOAT(trace.ent, ED_solid) == SOLID_BSP) + if(ED_Float(trace.ent, ED_solid) == SOLID_BSP) { - ED_FLOAT(ent, ED_flags) = (int32_t)ED_FLOAT(ent, ED_flags) | FL_ONGROUND; - ED_PEDICT(ent, ED_groundentity) = EDICT_TO_PROG(trace.ent); + ED_Float(ent, ED_flags) = (int32_t)ED_Float(ent, ED_flags) | FL_ONGROUND; + ED_PEdict(ent, ED_groundentity) = EdictProg(trace.ent); } } if(!trace.plane.normal[2]) @@ -325,7 +325,7 @@ int32_t SV_FlyMove(edict_t *ent, float time, trace_t *steptrace) if(numplanes >= MAX_CLIP_PLANES) { // this shouldn't really happen - VectorCopy(vec3_origin, ED_VECTOR(ent, ED_velocity)); + VectorCopy(vec3_origin, ED_Vector(ent, ED_velocity)); return 3; } @@ -351,7 +351,7 @@ int32_t SV_FlyMove(edict_t *ent, float time, trace_t *steptrace) if(i != numplanes) { // go along this plane - VectorCopy(new_velocity, ED_VECTOR(ent, ED_velocity)); + VectorCopy(new_velocity, ED_Vector(ent, ED_velocity)); } else { @@ -359,21 +359,21 @@ int32_t SV_FlyMove(edict_t *ent, float time, trace_t *steptrace) if(numplanes != 2) { // Con_Printf ("clip velocity, numplanes == %" PRIi32 "\n",numplanes); - VectorCopy(vec3_origin, ED_VECTOR(ent, ED_velocity)); + VectorCopy(vec3_origin, ED_Vector(ent, ED_velocity)); return 7; } CrossProduct(planes[0], planes[1], dir); - d = DotProduct(dir, ED_VECTOR(ent, ED_velocity)); - VectorScale(dir, d, ED_VECTOR(ent, ED_velocity)); + d = DotProduct(dir, ED_Vector(ent, ED_velocity)); + VectorScale(dir, d, ED_Vector(ent, ED_velocity)); } // // if original velocity is against the original velocity, stop dead // to avoid tiny occilations in sloping corners // - if(DotProduct(ED_VECTOR(ent, ED_velocity), primal_velocity) <= 0) + if(DotProduct(ED_Vector(ent, ED_velocity), primal_velocity) <= 0) { - VectorCopy(vec3_origin, ED_VECTOR(ent, ED_velocity)); + VectorCopy(vec3_origin, ED_Vector(ent, ED_velocity)); return blocked; } } @@ -399,7 +399,7 @@ void SV_AddGravity(edict_t *ent) else ent_gravity = 1.0; - ED_VECTOR(ent, ED_velocity)[2] -= ent_gravity * sv_gravity.value * host_frametime; + ED_Vector(ent, ED_velocity)[2] -= ent_gravity * sv_gravity.value * host_frametime; } @@ -423,17 +423,17 @@ trace_t SV_PushEntity(edict_t *ent, vec3_t push) trace_t trace; vec3_t end; - VectorAdd(ED_VECTOR(ent, ED_origin), push, end); + VectorAdd(ED_Vector(ent, ED_origin), push, end); - if(ED_FLOAT(ent, ED_movetype) == MOVETYPE_FLYMISSILE) - trace = SV_Move(ED_VECTOR(ent, ED_origin), ED_VECTOR(ent, ED_mins), ED_VECTOR(ent, ED_maxs), end, MOVE_MISSILE, ent); - else if(ED_FLOAT(ent, ED_solid) == SOLID_TRIGGER || ED_FLOAT(ent, ED_solid) == SOLID_NOT) + if(ED_Float(ent, ED_movetype) == MOVETYPE_FLYMISSILE) + trace = SV_Move(ED_Vector(ent, ED_origin), ED_Vector(ent, ED_mins), ED_Vector(ent, ED_maxs), end, MOVE_MISSILE, ent); + else if(ED_Float(ent, ED_solid) == SOLID_TRIGGER || ED_Float(ent, ED_solid) == SOLID_NOT) // only clip against bmodels - trace = SV_Move(ED_VECTOR(ent, ED_origin), ED_VECTOR(ent, ED_mins), ED_VECTOR(ent, ED_maxs), end, MOVE_NOMONSTERS, ent); + trace = SV_Move(ED_Vector(ent, ED_origin), ED_Vector(ent, ED_mins), ED_Vector(ent, ED_maxs), end, MOVE_NOMONSTERS, ent); else - trace = SV_Move(ED_VECTOR(ent, ED_origin), ED_VECTOR(ent, ED_mins), ED_VECTOR(ent, ED_maxs), end, MOVE_NORMAL, ent); + trace = SV_Move(ED_Vector(ent, ED_origin), ED_Vector(ent, ED_mins), ED_Vector(ent, ED_maxs), end, MOVE_NORMAL, ent); - VectorCopy(trace.endpos, ED_VECTOR(ent, ED_origin)); + VectorCopy(trace.endpos, ED_Vector(ent, ED_origin)); SV_LinkEdict(ent, true); if(trace.ent) @@ -459,25 +459,25 @@ void SV_PushMove(edict_t *pusher, float movetime) vec3_t *moved_from; //johnfitz -- dynamically allocate int32_t mark; //johnfitz - if(!ED_VECTOR(pusher, ED_velocity)[0] && !ED_VECTOR(pusher, ED_velocity)[1] && !ED_VECTOR(pusher, ED_velocity)[2]) + if(!ED_Vector(pusher, ED_velocity)[0] && !ED_Vector(pusher, ED_velocity)[1] && !ED_Vector(pusher, ED_velocity)[2]) { - ED_FLOAT(pusher, ED_ltime) += movetime; + ED_Float(pusher, ED_ltime) += movetime; return; } for(i = 0 ; i < 3 ; i++) { - move[i] = ED_VECTOR(pusher, ED_velocity)[i] * movetime; - mins[i] = ED_VECTOR(pusher, ED_absmin)[i] + move[i]; - maxs[i] = ED_VECTOR(pusher, ED_absmax)[i] + move[i]; + move[i] = ED_Vector(pusher, ED_velocity)[i] * movetime; + mins[i] = ED_Vector(pusher, ED_absmin)[i] + move[i]; + maxs[i] = ED_Vector(pusher, ED_absmax)[i] + move[i]; } - VectorCopy(ED_VECTOR(pusher, ED_origin), pushorig); + VectorCopy(ED_Vector(pusher, ED_origin), pushorig); // move the pusher to it's final position - VectorAdd(ED_VECTOR(pusher, ED_origin), move, ED_VECTOR(pusher, ED_origin)); - ED_FLOAT(pusher, ED_ltime) += movetime; + VectorAdd(ED_Vector(pusher, ED_origin), move, ED_Vector(pusher, ED_origin)); + ED_Float(pusher, ED_ltime) += movetime; SV_LinkEdict(pusher, false); //johnfitz -- dynamically allocate @@ -488,26 +488,26 @@ void SV_PushMove(edict_t *pusher, float movetime) // see if any solid entities are inside the final position num_moved = 0; - check = NEXT_EDICT(sv.edicts); - for(e = 1 ; e < sv.num_edicts ; e++, check = NEXT_EDICT(check)) + check = NextEdict(sv.edicts); + for(e = 1 ; e < sv.num_edicts ; e++, check = NextEdict(check)) { if(check->free) continue; - if(ED_FLOAT(check, ED_movetype) == MOVETYPE_PUSH - || ED_FLOAT(check, ED_movetype) == MOVETYPE_NONE - || ED_FLOAT(check, ED_movetype) == MOVETYPE_NOCLIP) + if(ED_Float(check, ED_movetype) == MOVETYPE_PUSH + || ED_Float(check, ED_movetype) == MOVETYPE_NONE + || ED_Float(check, ED_movetype) == MOVETYPE_NOCLIP) continue; // if the entity is standing on the pusher, it will definately be moved - if(!(((int32_t)ED_FLOAT(check, ED_flags) & FL_ONGROUND) - && PROG_TO_EDICT(ED_PEDICT(check, ED_groundentity)) == pusher)) + if(!(((int32_t)ED_Float(check, ED_flags) & FL_ONGROUND) + && ProgEdict(ED_PEdict(check, ED_groundentity)) == pusher)) { - if(ED_VECTOR(check, ED_absmin)[0] >= maxs[0] - || ED_VECTOR(check, ED_absmin)[1] >= maxs[1] - || ED_VECTOR(check, ED_absmin)[2] >= maxs[2] - || ED_VECTOR(check, ED_absmax)[0] <= mins[0] - || ED_VECTOR(check, ED_absmax)[1] <= mins[1] - || ED_VECTOR(check, ED_absmax)[2] <= mins[2]) + if(ED_Vector(check, ED_absmin)[0] >= maxs[0] + || ED_Vector(check, ED_absmin)[1] >= maxs[1] + || ED_Vector(check, ED_absmin)[2] >= maxs[2] + || ED_Vector(check, ED_absmax)[0] <= mins[0] + || ED_Vector(check, ED_absmax)[1] <= mins[1] + || ED_Vector(check, ED_absmax)[2] <= mins[2]) continue; // see if the ent's bbox is inside the pusher's final position @@ -516,54 +516,54 @@ void SV_PushMove(edict_t *pusher, float movetime) } // remove the onground flag for non-players - if(ED_FLOAT(check, ED_movetype) != MOVETYPE_WALK) - ED_FLOAT(check, ED_flags) = (int32_t)ED_FLOAT(check, ED_flags) & ~FL_ONGROUND; + if(ED_Float(check, ED_movetype) != MOVETYPE_WALK) + ED_Float(check, ED_flags) = (int32_t)ED_Float(check, ED_flags) & ~FL_ONGROUND; - VectorCopy(ED_VECTOR(check, ED_origin), entorig); - VectorCopy(ED_VECTOR(check, ED_origin), moved_from[num_moved]); + VectorCopy(ED_Vector(check, ED_origin), entorig); + VectorCopy(ED_Vector(check, ED_origin), moved_from[num_moved]); moved_edict[num_moved] = check; num_moved++; // try moving the contacted entity - ED_FLOAT(pusher, ED_solid) = SOLID_NOT; + ED_Float(pusher, ED_solid) = SOLID_NOT; SV_PushEntity(check, move); - ED_FLOAT(pusher, ED_solid) = SOLID_BSP; + ED_Float(pusher, ED_solid) = SOLID_BSP; // if it is still inside the pusher, block block = SV_TestEntityPosition(check); if(block) { // fail the move - if(ED_VECTOR(check, ED_mins)[0] == ED_VECTOR(check, ED_maxs)[0]) + if(ED_Vector(check, ED_mins)[0] == ED_Vector(check, ED_maxs)[0]) continue; - if(ED_FLOAT(check, ED_solid) == SOLID_NOT || ED_FLOAT(check, ED_solid) == SOLID_TRIGGER) + if(ED_Float(check, ED_solid) == SOLID_NOT || ED_Float(check, ED_solid) == SOLID_TRIGGER) { // corpse - ED_VECTOR(check, ED_mins)[0] = ED_VECTOR(check, ED_mins)[1] = 0; - VectorCopy(ED_VECTOR(check, ED_mins), ED_VECTOR(check, ED_maxs)); + ED_Vector(check, ED_mins)[0] = ED_Vector(check, ED_mins)[1] = 0; + VectorCopy(ED_Vector(check, ED_mins), ED_Vector(check, ED_maxs)); continue; } - VectorCopy(entorig, ED_VECTOR(check, ED_origin)); + VectorCopy(entorig, ED_Vector(check, ED_origin)); SV_LinkEdict(check, true); - VectorCopy(pushorig, ED_VECTOR(pusher, ED_origin)); + VectorCopy(pushorig, ED_Vector(pusher, ED_origin)); SV_LinkEdict(pusher, false); - ED_FLOAT(pusher, ED_ltime) -= movetime; + ED_Float(pusher, ED_ltime) -= movetime; // if the pusher has a "blocked" function, call it // otherwise, just stay in place until the obstacle is gone - if(ED_FUNC(pusher, ED_blocked)) + if(ED_Func(pusher, ED_blocked)) { - G_PEDICT(GBL_self) = EDICT_TO_PROG(pusher); - G_PEDICT(GBL_other) = EDICT_TO_PROG(check); - PR_ExecuteProgram(ED_FUNC(pusher, ED_blocked)); + G_PEdict(GBL_self) = EdictProg(pusher); + G_PEdict(GBL_other) = EdictProg(check); + PR_ExecuteProgram(ED_Func(pusher, ED_blocked)); } // move back any entities we already moved for(i = 0 ; i < num_moved ; i++) { - VectorCopy(moved_from[i], ED_VECTOR(moved_edict[i], ED_origin)); + VectorCopy(moved_from[i], ED_Vector(moved_edict[i], ED_origin)); SV_LinkEdict(moved_edict[i], false); } Hunk_FreeToLowMark(mark); //johnfitz @@ -587,12 +587,12 @@ void SV_Physics_Pusher(edict_t *ent) float oldltime; float movetime; - oldltime = ED_FLOAT(ent, ED_ltime); + oldltime = ED_Float(ent, ED_ltime); - thinktime = ED_FLOAT(ent, ED_nextthink); - if(thinktime < ED_FLOAT(ent, ED_ltime) + host_frametime) + thinktime = ED_Float(ent, ED_nextthink); + if(thinktime < ED_Float(ent, ED_ltime) + host_frametime) { - movetime = thinktime - ED_FLOAT(ent, ED_ltime); + movetime = thinktime - ED_Float(ent, ED_ltime); if(movetime < 0) movetime = 0; } @@ -601,16 +601,16 @@ void SV_Physics_Pusher(edict_t *ent) if(movetime) { - SV_PushMove(ent, movetime); // advances ED_FLOAT(ent, ED_ltime) if not blocked + SV_PushMove(ent, movetime); // advances ED_Float(ent, ED_ltime) if not blocked } - if(thinktime > oldltime && thinktime <= ED_FLOAT(ent, ED_ltime)) + if(thinktime > oldltime && thinktime <= ED_Float(ent, ED_ltime)) { - ED_FLOAT(ent, ED_nextthink) = 0; - G_FLOAT(GBL_time) = sv.time; - G_PEDICT(GBL_self) = EDICT_TO_PROG(ent); - G_PEDICT(GBL_other) = EDICT_TO_PROG(sv.edicts); - PR_ExecuteProgram(ED_FUNC(ent, ED_think)); + ED_Float(ent, ED_nextthink) = 0; + G_Float(GBL_time) = sv.time; + G_PEdict(GBL_self) = EdictProg(ent); + G_PEdict(GBL_other) = EdictProg(sv.edicts); + PR_ExecuteProgram(ED_Func(ent, ED_think)); if(ent->free) return; } @@ -642,12 +642,12 @@ void SV_CheckStuck(edict_t *ent) if(!SV_TestEntityPosition(ent)) { - VectorCopy(ED_VECTOR(ent, ED_origin), ED_VECTOR(ent, ED_oldorigin)); + VectorCopy(ED_Vector(ent, ED_origin), ED_Vector(ent, ED_oldorigin)); return; } - VectorCopy(ED_VECTOR(ent, ED_origin), org); - VectorCopy(ED_VECTOR(ent, ED_oldorigin), ED_VECTOR(ent, ED_origin)); + VectorCopy(ED_Vector(ent, ED_origin), org); + VectorCopy(ED_Vector(ent, ED_oldorigin), ED_Vector(ent, ED_origin)); if(!SV_TestEntityPosition(ent)) { Con_DPrintf("Unstuck.\n"); @@ -659,9 +659,9 @@ void SV_CheckStuck(edict_t *ent) for(i = -1 ; i <= 1 ; i++) for(j = -1 ; j <= 1 ; j++) { - ED_VECTOR(ent, ED_origin)[0] = org[0] + i; - ED_VECTOR(ent, ED_origin)[1] = org[1] + j; - ED_VECTOR(ent, ED_origin)[2] = org[2] + z; + ED_Vector(ent, ED_origin)[0] = org[0] + i; + ED_Vector(ent, ED_origin)[1] = org[1] + j; + ED_Vector(ent, ED_origin)[2] = org[2] + z; if(!SV_TestEntityPosition(ent)) { Con_DPrintf("Unstuck.\n"); @@ -670,7 +670,7 @@ void SV_CheckStuck(edict_t *ent) } } - VectorCopy(org, ED_VECTOR(ent, ED_origin)); + VectorCopy(org, ED_Vector(ent, ED_origin)); Con_DPrintf("player is stuck.\n"); } @@ -685,30 +685,30 @@ bool SV_CheckWater(edict_t *ent) vec3_t point; int32_t cont; - point[0] = ED_VECTOR(ent, ED_origin)[0]; - point[1] = ED_VECTOR(ent, ED_origin)[1]; - point[2] = ED_VECTOR(ent, ED_origin)[2] + ED_VECTOR(ent, ED_mins)[2] + 1; + point[0] = ED_Vector(ent, ED_origin)[0]; + point[1] = ED_Vector(ent, ED_origin)[1]; + point[2] = ED_Vector(ent, ED_origin)[2] + ED_Vector(ent, ED_mins)[2] + 1; - ED_FLOAT(ent, ED_waterlevel) = 0; - ED_FLOAT(ent, ED_watertype) = CONTENTS_EMPTY; + ED_Float(ent, ED_waterlevel) = 0; + ED_Float(ent, ED_watertype) = CONTENTS_EMPTY; cont = SV_PointContents(point); if(cont <= CONTENTS_WATER) { - ED_FLOAT(ent, ED_watertype) = cont; - ED_FLOAT(ent, ED_waterlevel) = 1; - point[2] = ED_VECTOR(ent, ED_origin)[2] + (ED_VECTOR(ent, ED_mins)[2] + ED_VECTOR(ent, ED_maxs)[2]) * 0.5; + ED_Float(ent, ED_watertype) = cont; + ED_Float(ent, ED_waterlevel) = 1; + point[2] = ED_Vector(ent, ED_origin)[2] + (ED_Vector(ent, ED_mins)[2] + ED_Vector(ent, ED_maxs)[2]) * 0.5; cont = SV_PointContents(point); if(cont <= CONTENTS_WATER) { - ED_FLOAT(ent, ED_waterlevel) = 2; - point[2] = ED_VECTOR(ent, ED_origin)[2] + ED_VECTOR(ent, ED_view_ofs)[2]; + ED_Float(ent, ED_waterlevel) = 2; + point[2] = ED_Vector(ent, ED_origin)[2] + ED_Vector(ent, ED_view_ofs)[2]; cont = SV_PointContents(point); if(cont <= CONTENTS_WATER) - ED_FLOAT(ent, ED_waterlevel) = 3; + ED_Float(ent, ED_waterlevel) = 3; } } - return ED_FLOAT(ent, ED_waterlevel) > 1; + return ED_Float(ent, ED_waterlevel) > 1; } /* @@ -723,7 +723,7 @@ void SV_WallFriction(edict_t *ent, trace_t *trace) float d, i; vec3_t into, side; - AngleVectors(ED_VECTOR(ent, ED_v_angle), forward, right, up); + AngleVectors(ED_Vector(ent, ED_v_angle), forward, right, up); d = DotProduct(trace->plane.normal, forward); d += 0.5; @@ -731,12 +731,12 @@ void SV_WallFriction(edict_t *ent, trace_t *trace) return; // cut the tangential velocity - i = DotProduct(trace->plane.normal, ED_VECTOR(ent, ED_velocity)); + i = DotProduct(trace->plane.normal, ED_Vector(ent, ED_velocity)); VectorScale(trace->plane.normal, i, into); - VectorSubtract(ED_VECTOR(ent, ED_velocity), into, side); + VectorSubtract(ED_Vector(ent, ED_velocity), into, side); - ED_VECTOR(ent, ED_velocity)[0] = side[0] * (1 + d); - ED_VECTOR(ent, ED_velocity)[1] = side[1] * (1 + d); + ED_Vector(ent, ED_velocity)[0] = side[0] * (1 + d); + ED_Vector(ent, ED_velocity)[1] = side[1] * (1 + d); } /* @@ -759,7 +759,7 @@ int32_t SV_TryUnstick(edict_t *ent, vec3_t oldvel) int32_t clip; trace_t steptrace; - VectorCopy(ED_VECTOR(ent, ED_origin), oldorg); + VectorCopy(ED_Vector(ent, ED_origin), oldorg); VectorCopy(vec3_origin, dir); for(i = 0 ; i < 8 ; i++) @@ -804,23 +804,23 @@ int32_t SV_TryUnstick(edict_t *ent, vec3_t oldvel) SV_PushEntity(ent, dir); // retry the original move - ED_VECTOR(ent, ED_velocity)[0] = oldvel[0]; - ED_VECTOR(ent, ED_velocity)[1] = oldvel[1]; - ED_VECTOR(ent, ED_velocity)[2] = 0; + ED_Vector(ent, ED_velocity)[0] = oldvel[0]; + ED_Vector(ent, ED_velocity)[1] = oldvel[1]; + ED_Vector(ent, ED_velocity)[2] = 0; clip = SV_FlyMove(ent, 0.1, &steptrace); - if(fabs(oldorg[1] - ED_VECTOR(ent, ED_origin)[1]) > 4 - || fabs(oldorg[0] - ED_VECTOR(ent, ED_origin)[0]) > 4) + if(fabs(oldorg[1] - ED_Vector(ent, ED_origin)[1]) > 4 + || fabs(oldorg[0] - ED_Vector(ent, ED_origin)[0]) > 4) { //Con_DPrintf ("unstuck!\n"); return clip; } // go back to the original pos and try again - VectorCopy(oldorg, ED_VECTOR(ent, ED_origin)); + VectorCopy(oldorg, ED_Vector(ent, ED_origin)); } - VectorCopy(vec3_origin, ED_VECTOR(ent, ED_velocity)); + VectorCopy(vec3_origin, ED_Vector(ent, ED_velocity)); return 7; // still not moving } @@ -844,36 +844,36 @@ void SV_WalkMove(edict_t *ent) // // do a regular slide move unless it looks like you ran into a step // - oldonground = (int32_t)ED_FLOAT(ent, ED_flags) & FL_ONGROUND; - ED_FLOAT(ent, ED_flags) = (int32_t)ED_FLOAT(ent, ED_flags) & ~FL_ONGROUND; + oldonground = (int32_t)ED_Float(ent, ED_flags) & FL_ONGROUND; + ED_Float(ent, ED_flags) = (int32_t)ED_Float(ent, ED_flags) & ~FL_ONGROUND; - VectorCopy(ED_VECTOR(ent, ED_origin), oldorg); - VectorCopy(ED_VECTOR(ent, ED_velocity), oldvel); + VectorCopy(ED_Vector(ent, ED_origin), oldorg); + VectorCopy(ED_Vector(ent, ED_velocity), oldvel); clip = SV_FlyMove(ent, host_frametime, &steptrace); if(!(clip & 2)) return; // move didn't block on a step - if(!oldonground && ED_FLOAT(ent, ED_waterlevel) == 0) + if(!oldonground && ED_Float(ent, ED_waterlevel) == 0) return; // don't stair up while jumping - if(ED_FLOAT(ent, ED_movetype) != MOVETYPE_WALK) + if(ED_Float(ent, ED_movetype) != MOVETYPE_WALK) return; // gibbed by a trigger if(sv_nostep.value) return; - if((int32_t)ED_FLOAT(sv_player, ED_flags) & FL_WATERJUMP) + if((int32_t)ED_Float(sv_player, ED_flags) & FL_WATERJUMP) return; - VectorCopy(ED_VECTOR(ent, ED_origin), nosteporg); - VectorCopy(ED_VECTOR(ent, ED_velocity), nostepvel); + VectorCopy(ED_Vector(ent, ED_origin), nosteporg); + VectorCopy(ED_Vector(ent, ED_velocity), nostepvel); // // try moving up and forward to go up a step // - VectorCopy(oldorg, ED_VECTOR(ent, ED_origin)); // back to start pos + VectorCopy(oldorg, ED_Vector(ent, ED_origin)); // back to start pos VectorCopy(vec3_origin, upmove); VectorCopy(vec3_origin, downmove); @@ -884,17 +884,17 @@ void SV_WalkMove(edict_t *ent) SV_PushEntity(ent, upmove); // FIXME: don't link? // move forward - ED_VECTOR(ent, ED_velocity)[0] = oldvel[0]; - ED_VECTOR(ent, ED_velocity)[1] = oldvel[1]; - ED_VECTOR(ent, ED_velocity)[2] = 0; + ED_Vector(ent, ED_velocity)[0] = oldvel[0]; + ED_Vector(ent, ED_velocity)[1] = oldvel[1]; + ED_Vector(ent, ED_velocity)[2] = 0; clip = SV_FlyMove(ent, host_frametime, &steptrace); // check for stuckness, possibly due to the limited precision of floats // in the clipping hulls if(clip) { - if(fabs(oldorg[1] - ED_VECTOR(ent, ED_origin)[1]) < 0.03125 - && fabs(oldorg[0] - ED_VECTOR(ent, ED_origin)[0]) < 0.03125) + if(fabs(oldorg[1] - ED_Vector(ent, ED_origin)[1]) < 0.03125 + && fabs(oldorg[0] - ED_Vector(ent, ED_origin)[0]) < 0.03125) { // stepping up didn't make any progress clip = SV_TryUnstick(ent, oldvel); @@ -910,10 +910,10 @@ void SV_WalkMove(edict_t *ent) if(downtrace.plane.normal[2] > 0.7) { - if(ED_FLOAT(ent, ED_solid) == SOLID_BSP) + if(ED_Float(ent, ED_solid) == SOLID_BSP) { - ED_FLOAT(ent, ED_flags) = (int32_t)ED_FLOAT(ent, ED_flags) | FL_ONGROUND; - ED_PEDICT(ent, ED_groundentity) = EDICT_TO_PROG(downtrace.ent); + ED_Float(ent, ED_flags) = (int32_t)ED_Float(ent, ED_flags) | FL_ONGROUND; + ED_PEdict(ent, ED_groundentity) = EdictProg(downtrace.ent); } } else @@ -921,8 +921,8 @@ void SV_WalkMove(edict_t *ent) // if the push down didn't end up on good ground, use the move without // the step up. This happens near wall / slope combinations, and can // cause the player to hop up higher on a slope too steep to climb - VectorCopy(nosteporg, ED_VECTOR(ent, ED_origin)); - VectorCopy(nostepvel, ED_VECTOR(ent, ED_velocity)); + VectorCopy(nosteporg, ED_Vector(ent, ED_origin)); + VectorCopy(nostepvel, ED_Vector(ent, ED_velocity)); } } @@ -942,9 +942,9 @@ void SV_Physics_Client(edict_t *ent, int32_t num) // // call standard client pre-think // - G_FLOAT(GBL_time) = sv.time; - G_PEDICT(GBL_self) = EDICT_TO_PROG(ent); - PR_ExecuteProgram(G_FUNC(GBL_PlayerPreThink)); + G_Float(GBL_time) = sv.time; + G_PEdict(GBL_self) = EdictProg(ent); + PR_ExecuteProgram(G_Func(GBL_PlayerPreThink)); // // do a move @@ -954,7 +954,7 @@ void SV_Physics_Client(edict_t *ent, int32_t num) // // decide which move function to call // - switch((int32_t)ED_FLOAT(ent, ED_movetype)) + switch((int32_t)ED_Float(ent, ED_movetype)) { case MOVETYPE_NONE: if(!SV_RunThink(ent)) @@ -964,7 +964,7 @@ void SV_Physics_Client(edict_t *ent, int32_t num) case MOVETYPE_WALK: if(!SV_RunThink(ent)) return; - if(!SV_CheckWater(ent) && !((int32_t)ED_FLOAT(ent, ED_flags) & FL_WATERJUMP)) + if(!SV_CheckWater(ent) && !((int32_t)ED_Float(ent, ED_flags) & FL_WATERJUMP)) SV_AddGravity(ent); SV_CheckStuck(ent); SV_WalkMove(ent); @@ -984,11 +984,11 @@ void SV_Physics_Client(edict_t *ent, int32_t num) case MOVETYPE_NOCLIP: if(!SV_RunThink(ent)) return; - VectorMA(ED_VECTOR(ent, ED_origin), host_frametime, ED_VECTOR(ent, ED_velocity), ED_VECTOR(ent, ED_origin)); + VectorMA(ED_Vector(ent, ED_origin), host_frametime, ED_Vector(ent, ED_velocity), ED_Vector(ent, ED_origin)); break; default: - Sys_Error("SV_Physics_client: bad movetype %" PRIi32 "", (int32_t)ED_FLOAT(ent, ED_movetype)); + Sys_Error("SV_Physics_client: bad movetype %" PRIi32, (int32_t)ED_Float(ent, ED_movetype)); } // @@ -996,9 +996,9 @@ void SV_Physics_Client(edict_t *ent, int32_t num) // SV_LinkEdict(ent, true); - G_FLOAT(GBL_time) = sv.time; - G_PEDICT(GBL_self) = EDICT_TO_PROG(ent); - PR_ExecuteProgram(G_FUNC(GBL_PlayerPostThink)); + G_Float(GBL_time) = sv.time; + G_PEdict(GBL_self) = EdictProg(ent); + PR_ExecuteProgram(G_Func(GBL_PlayerPostThink)); } //============================================================================ @@ -1029,8 +1029,8 @@ void SV_Physics_Noclip(edict_t *ent) if(!SV_RunThink(ent)) return; - VectorMA(ED_VECTOR(ent, ED_angles), host_frametime, ED_VECTOR(ent, ED_avelocity), ED_VECTOR(ent, ED_angles)); - VectorMA(ED_VECTOR(ent, ED_origin), host_frametime, ED_VECTOR(ent, ED_velocity), ED_VECTOR(ent, ED_origin)); + VectorMA(ED_Vector(ent, ED_angles), host_frametime, ED_Vector(ent, ED_avelocity), ED_Vector(ent, ED_angles)); + VectorMA(ED_Vector(ent, ED_origin), host_frametime, ED_Vector(ent, ED_velocity), ED_Vector(ent, ED_origin)); SV_LinkEdict(ent, false); } @@ -1053,35 +1053,35 @@ void SV_CheckWaterTransition(edict_t *ent) { int32_t cont; - cont = SV_PointContents(ED_VECTOR(ent, ED_origin)); + cont = SV_PointContents(ED_Vector(ent, ED_origin)); - if(!ED_FLOAT(ent, ED_watertype)) + if(!ED_Float(ent, ED_watertype)) { // just spawned here - ED_FLOAT(ent, ED_watertype) = cont; - ED_FLOAT(ent, ED_waterlevel) = 1; + ED_Float(ent, ED_watertype) = cont; + ED_Float(ent, ED_waterlevel) = 1; return; } if(cont <= CONTENTS_WATER) { - if(ED_FLOAT(ent, ED_watertype) == CONTENTS_EMPTY) + if(ED_Float(ent, ED_watertype) == CONTENTS_EMPTY) { // just crossed into water SV_StartSound(ent, 0, "misc/h2ohit1.wav", 255, 1); } - ED_FLOAT(ent, ED_watertype) = cont; - ED_FLOAT(ent, ED_waterlevel) = 1; + ED_Float(ent, ED_watertype) = cont; + ED_Float(ent, ED_waterlevel) = 1; } else { - if(ED_FLOAT(ent, ED_watertype) != CONTENTS_EMPTY) + if(ED_Float(ent, ED_watertype) != CONTENTS_EMPTY) { // just crossed into water SV_StartSound(ent, 0, "misc/h2ohit1.wav", 255, 1); } - ED_FLOAT(ent, ED_watertype) = CONTENTS_EMPTY; - ED_FLOAT(ent, ED_waterlevel) = cont; + ED_Float(ent, ED_watertype) = CONTENTS_EMPTY; + ED_Float(ent, ED_waterlevel) = cont; } } @@ -1103,43 +1103,43 @@ void SV_Physics_Toss(edict_t *ent) return; // if onground, return without moving - if(((int32_t)ED_FLOAT(ent, ED_flags) & FL_ONGROUND)) + if(((int32_t)ED_Float(ent, ED_flags) & FL_ONGROUND)) return; SV_CheckVelocity(ent); // add gravity - if(ED_FLOAT(ent, ED_movetype) != MOVETYPE_FLY - && ED_FLOAT(ent, ED_movetype) != MOVETYPE_FLYMISSILE) + if(ED_Float(ent, ED_movetype) != MOVETYPE_FLY + && ED_Float(ent, ED_movetype) != MOVETYPE_FLYMISSILE) SV_AddGravity(ent); // move angles - VectorMA(ED_VECTOR(ent, ED_angles), host_frametime, ED_VECTOR(ent, ED_avelocity), ED_VECTOR(ent, ED_angles)); + VectorMA(ED_Vector(ent, ED_angles), host_frametime, ED_Vector(ent, ED_avelocity), ED_Vector(ent, ED_angles)); // move origin - VectorScale(ED_VECTOR(ent, ED_velocity), host_frametime, move); + VectorScale(ED_Vector(ent, ED_velocity), host_frametime, move); trace = SV_PushEntity(ent, move); if(trace.fraction == 1) return; if(ent->free) return; - if(ED_FLOAT(ent, ED_movetype) == MOVETYPE_BOUNCE) + if(ED_Float(ent, ED_movetype) == MOVETYPE_BOUNCE) backoff = 1.5; else backoff = 1; - ClipVelocity(ED_VECTOR(ent, ED_velocity), trace.plane.normal, ED_VECTOR(ent, ED_velocity), backoff); + ClipVelocity(ED_Vector(ent, ED_velocity), trace.plane.normal, ED_Vector(ent, ED_velocity), backoff); // stop if on ground if(trace.plane.normal[2] > 0.7) { - if(ED_VECTOR(ent, ED_velocity)[2] < 60 || ED_FLOAT(ent, ED_movetype) != MOVETYPE_BOUNCE) + if(ED_Vector(ent, ED_velocity)[2] < 60 || ED_Float(ent, ED_movetype) != MOVETYPE_BOUNCE) { - ED_FLOAT(ent, ED_flags) = (int32_t)ED_FLOAT(ent, ED_flags) | FL_ONGROUND; - ED_PEDICT(ent, ED_groundentity) = EDICT_TO_PROG(trace.ent); - VectorCopy(vec3_origin, ED_VECTOR(ent, ED_velocity)); - VectorCopy(vec3_origin, ED_VECTOR(ent, ED_avelocity)); + ED_Float(ent, ED_flags) = (int32_t)ED_Float(ent, ED_flags) | FL_ONGROUND; + ED_PEdict(ent, ED_groundentity) = EdictProg(trace.ent); + VectorCopy(vec3_origin, ED_Vector(ent, ED_velocity)); + VectorCopy(vec3_origin, ED_Vector(ent, ED_avelocity)); } } @@ -1171,9 +1171,9 @@ void SV_Physics_Step(edict_t *ent) bool hitsound; // freefall if not onground - if(!((int32_t)ED_FLOAT(ent, ED_flags) & (FL_ONGROUND | FL_FLY | FL_SWIM))) + if(!((int32_t)ED_Float(ent, ED_flags) & (FL_ONGROUND | FL_FLY | FL_SWIM))) { - if(ED_VECTOR(ent, ED_velocity)[2] < sv_gravity.value * -0.1) + if(ED_Vector(ent, ED_velocity)[2] < sv_gravity.value * -0.1) hitsound = true; else hitsound = false; @@ -1183,7 +1183,7 @@ void SV_Physics_Step(edict_t *ent) SV_FlyMove(ent, host_frametime, NULL); SV_LinkEdict(ent, true); - if((int32_t)ED_FLOAT(ent, ED_flags) & FL_ONGROUND) // just hit ground + if((int32_t)ED_Float(ent, ED_flags) & FL_ONGROUND) // just hit ground { if(hitsound) SV_StartSound(ent, 0, "demon/dland2.wav", 255, 1); @@ -1212,10 +1212,10 @@ void SV_Physics(void) edict_t *ent; // let the progs know that a new frame has started - G_PEDICT(GBL_self) = EDICT_TO_PROG(sv.edicts); - G_PEDICT(GBL_other) = EDICT_TO_PROG(sv.edicts); - G_FLOAT(GBL_time) = sv.time; - PR_ExecuteProgram(G_FUNC(GBL_StartFrame)); + G_PEdict(GBL_self) = EdictProg(sv.edicts); + G_PEdict(GBL_other) = EdictProg(sv.edicts); + G_Float(GBL_time) = sv.time; + PR_ExecuteProgram(G_Func(GBL_StartFrame)); //SV_CheckAllEnts (); @@ -1229,38 +1229,38 @@ void SV_Physics(void) else entity_cap = sv.num_edicts; - //for (i=0 ; ifree) continue; - if(G_FLOAT(GBL_force_retouch)) + if(G_Float(GBL_force_retouch)) { SV_LinkEdict(ent, true); // force retouch even for stationary } if(i > 0 && i <= svs.maxclients) SV_Physics_Client(ent, i); - else if(ED_FLOAT(ent, ED_movetype) == MOVETYPE_PUSH) + else if(ED_Float(ent, ED_movetype) == MOVETYPE_PUSH) SV_Physics_Pusher(ent); - else if(ED_FLOAT(ent, ED_movetype) == MOVETYPE_NONE) + else if(ED_Float(ent, ED_movetype) == MOVETYPE_NONE) SV_Physics_None(ent); - else if(ED_FLOAT(ent, ED_movetype) == MOVETYPE_NOCLIP) + else if(ED_Float(ent, ED_movetype) == MOVETYPE_NOCLIP) SV_Physics_Noclip(ent); - else if(ED_FLOAT(ent, ED_movetype) == MOVETYPE_STEP) + else if(ED_Float(ent, ED_movetype) == MOVETYPE_STEP) SV_Physics_Step(ent); - else if(ED_FLOAT(ent, ED_movetype) == MOVETYPE_TOSS - || ED_FLOAT(ent, ED_movetype) == MOVETYPE_BOUNCE - || ED_FLOAT(ent, ED_movetype) == MOVETYPE_FLY - || ED_FLOAT(ent, ED_movetype) == MOVETYPE_FLYMISSILE) + else if(ED_Float(ent, ED_movetype) == MOVETYPE_TOSS + || ED_Float(ent, ED_movetype) == MOVETYPE_BOUNCE + || ED_Float(ent, ED_movetype) == MOVETYPE_FLY + || ED_Float(ent, ED_movetype) == MOVETYPE_FLYMISSILE) SV_Physics_Toss(ent); else - Sys_Error("SV_Physics: bad movetype %" PRIi32 "", (int32_t)ED_FLOAT(ent, ED_movetype)); + Sys_Error("SV_Physics: bad movetype %" PRIi32, (int32_t)ED_Float(ent, ED_movetype)); } - if(G_FLOAT(GBL_force_retouch)) - G_FLOAT(GBL_force_retouch)--; + if(G_Float(GBL_force_retouch)) + G_Float(GBL_force_retouch)--; if(!sv_freezenonclients.value) sv.time += host_frametime; diff --git a/source/sv_user.c b/source/sv_user.c index 58013c6..84e7680 100644 --- a/source/sv_user.c +++ b/source/sv_user.c @@ -58,18 +58,18 @@ void SV_SetIdealPitch(void) int32_t i, j; int32_t step, dir, steps; - if(!((int32_t)ED_FLOAT(sv_player, ED_flags) & FL_ONGROUND)) + if(!((int32_t)ED_Float(sv_player, ED_flags) & FL_ONGROUND)) return; - angleval = ED_VECTOR(sv_player, ED_angles)[YAW] * PI * 2 / 360; + angleval = ED_Vector(sv_player, ED_angles)[YAW] * PI * 2 / 360; sinval = sin(angleval); cosval = cos(angleval); for(i = 0 ; i < MAX_FORWARD ; i++) { - top[0] = ED_VECTOR(sv_player, ED_origin)[0] + cosval * (i + 3) * 12; - top[1] = ED_VECTOR(sv_player, ED_origin)[1] + sinval * (i + 3) * 12; - top[2] = ED_VECTOR(sv_player, ED_origin)[2] + ED_VECTOR(sv_player, ED_view_ofs)[2]; + top[0] = ED_Vector(sv_player, ED_origin)[0] + cosval * (i + 3) * 12; + top[1] = ED_Vector(sv_player, ED_origin)[1] + sinval * (i + 3) * 12; + top[2] = ED_Vector(sv_player, ED_origin)[2] + ED_Vector(sv_player, ED_view_ofs)[2]; bottom[0] = top[0]; bottom[1] = top[1]; @@ -102,13 +102,13 @@ void SV_SetIdealPitch(void) if(!dir) { - ED_FLOAT(sv_player, ED_idealpitch) = 0; + ED_Float(sv_player, ED_idealpitch) = 0; return; } if(steps < 2) return; - ED_FLOAT(sv_player, ED_idealpitch) = -dir * sv_idealpitchscale.value; + ED_Float(sv_player, ED_idealpitch) = -dir * sv_idealpitchscale.value; } @@ -135,7 +135,7 @@ void SV_UserFriction(void) // if the leading edge is over a dropoff, increase friction start[0] = stop[0] = origin[0] + vel[0] / speed * 16; start[1] = stop[1] = origin[1] + vel[1] / speed * 16; - start[2] = origin[2] + ED_VECTOR(sv_player, ED_mins)[2]; + start[2] = origin[2] + ED_Vector(sv_player, ED_mins)[2]; stop[2] = start[2] - 34; trace = SV_Move(start, vec3_origin, vec3_origin, stop, true, sv_player); @@ -208,12 +208,12 @@ void DropPunchAngle(void) { float len; - len = VectorNormalize(ED_VECTOR(sv_player, ED_punchangle)); + len = VectorNormalize(ED_Vector(sv_player, ED_punchangle)); len -= 10 * host_frametime; if(len < 0) len = 0; - VectorScale(ED_VECTOR(sv_player, ED_punchangle), len, ED_VECTOR(sv_player, ED_punchangle)); + VectorScale(ED_Vector(sv_player, ED_punchangle), len, ED_Vector(sv_player, ED_punchangle)); } /* @@ -231,7 +231,7 @@ void SV_WaterMove(void) // // user intentions // - AngleVectors(ED_VECTOR(sv_player, ED_v_angle), forward, right, up); + AngleVectors(ED_Vector(sv_player, ED_v_angle), forward, right, up); for(i = 0 ; i < 3 ; i++) wishvel[i] = forward[i] * cmd.forwardmove + right[i] * cmd.sidemove; @@ -284,14 +284,14 @@ void SV_WaterMove(void) void SV_WaterJump(void) { - if(sv.time > ED_FLOAT(sv_player, ED_teleport_time) - || !ED_FLOAT(sv_player, ED_waterlevel)) + if(sv.time > ED_Float(sv_player, ED_teleport_time) + || !ED_Float(sv_player, ED_waterlevel)) { - ED_FLOAT(sv_player, ED_flags) = (int32_t)ED_FLOAT(sv_player, ED_flags) & ~FL_WATERJUMP; - ED_FLOAT(sv_player, ED_teleport_time) = 0; + ED_Float(sv_player, ED_flags) = (int32_t)ED_Float(sv_player, ED_flags) & ~FL_WATERJUMP; + ED_Float(sv_player, ED_teleport_time) = 0; } - ED_VECTOR(sv_player, ED_velocity)[0] = ED_VECTOR(sv_player, ED_movedir)[0]; - ED_VECTOR(sv_player, ED_velocity)[1] = ED_VECTOR(sv_player, ED_movedir)[1]; + ED_Vector(sv_player, ED_velocity)[0] = ED_Vector(sv_player, ED_movedir)[0]; + ED_Vector(sv_player, ED_velocity)[1] = ED_Vector(sv_player, ED_movedir)[1]; } /* @@ -303,7 +303,7 @@ new, alternate noclip. old noclip is still handled in SV_AirMove */ void SV_NoclipMove(void) { - AngleVectors(ED_VECTOR(sv_player, ED_v_angle), forward, right, up); + AngleVectors(ED_Vector(sv_player, ED_v_angle), forward, right, up); velocity[0] = forward[0] * cmd.forwardmove + right[0] * cmd.sidemove; velocity[1] = forward[1] * cmd.forwardmove + right[1] * cmd.sidemove; @@ -329,19 +329,19 @@ void SV_AirMove(void) float wishspeed; float fmove, smove; - AngleVectors(ED_VECTOR(sv_player, ED_angles), forward, right, up); + AngleVectors(ED_Vector(sv_player, ED_angles), forward, right, up); fmove = cmd.forwardmove; smove = cmd.sidemove; // hack to not let you back into teleporter - if(sv.time < ED_FLOAT(sv_player, ED_teleport_time) && fmove < 0) + if(sv.time < ED_Float(sv_player, ED_teleport_time) && fmove < 0) fmove = 0; for(i = 0 ; i < 3 ; i++) wishvel[i] = forward[i] * fmove + right[i] * smove; - if((int32_t)ED_FLOAT(sv_player, ED_movetype) != MOVETYPE_WALK) + if((int32_t)ED_Float(sv_player, ED_movetype) != MOVETYPE_WALK) wishvel[2] = cmd.upmove; else wishvel[2] = 0; @@ -354,7 +354,7 @@ void SV_AirMove(void) wishspeed = sv_maxspeed.value; } - if(ED_FLOAT(sv_player, ED_movetype) == MOVETYPE_NOCLIP) + if(ED_Float(sv_player, ED_movetype) == MOVETYPE_NOCLIP) { // noclip VectorCopy(wishvel, velocity); @@ -383,37 +383,37 @@ void SV_ClientThink(void) { vec3_t v_angle; - if(ED_FLOAT(sv_player, ED_movetype) == MOVETYPE_NONE) + if(ED_Float(sv_player, ED_movetype) == MOVETYPE_NONE) return; - onground = (int32_t)ED_FLOAT(sv_player, ED_flags) & FL_ONGROUND; + onground = (int32_t)ED_Float(sv_player, ED_flags) & FL_ONGROUND; - origin = ED_VECTOR(sv_player, ED_origin); - velocity = ED_VECTOR(sv_player, ED_velocity); + origin = ED_Vector(sv_player, ED_origin); + velocity = ED_Vector(sv_player, ED_velocity); DropPunchAngle(); // // if dead, behave differently // - if(ED_FLOAT(sv_player, ED_health) <= 0) + if(ED_Float(sv_player, ED_health) <= 0) return; // // angles // show 1/3 the pitch angle and all the roll angle cmd = host_client->cmd; - angles = ED_VECTOR(sv_player, ED_angles); + angles = ED_Vector(sv_player, ED_angles); - VectorAdd(ED_VECTOR(sv_player, ED_v_angle), ED_VECTOR(sv_player, ED_punchangle), v_angle); - angles[ROLL] = V_CalcRoll(ED_VECTOR(sv_player, ED_angles), ED_VECTOR(sv_player, ED_velocity)) * 4; - if(!ED_FLOAT(sv_player, ED_fixangle)) + VectorAdd(ED_Vector(sv_player, ED_v_angle), ED_Vector(sv_player, ED_punchangle), v_angle); + angles[ROLL] = V_CalcRoll(ED_Vector(sv_player, ED_angles), ED_Vector(sv_player, ED_velocity)) * 4; + if(!ED_Float(sv_player, ED_fixangle)) { angles[PITCH] = -v_angle[PITCH] / 3; angles[YAW] = v_angle[YAW]; } - if((int32_t)ED_FLOAT(sv_player, ED_flags) & FL_WATERJUMP) + if((int32_t)ED_Float(sv_player, ED_flags) & FL_WATERJUMP) { SV_WaterJump(); return; @@ -422,9 +422,9 @@ void SV_ClientThink(void) // walk // //johnfitz -- alternate noclip - if(ED_FLOAT(sv_player, ED_movetype) == MOVETYPE_NOCLIP && sv_altnoclip.value) + if(ED_Float(sv_player, ED_movetype) == MOVETYPE_NOCLIP && sv_altnoclip.value) SV_NoclipMove(); - else if(ED_FLOAT(sv_player, ED_waterlevel) >= 2 && ED_FLOAT(sv_player, ED_movetype) != MOVETYPE_NOCLIP) + else if(ED_Float(sv_player, ED_waterlevel) >= 2 && ED_Float(sv_player, ED_movetype) != MOVETYPE_NOCLIP) SV_WaterMove(); else SV_AirMove(); @@ -457,7 +457,7 @@ void SV_ReadClientMove(usercmd_t *move) angle[i] = MSG_ReadAngle16(sv.protocolflags); //johnfitz - VectorCopy(angle, ED_VECTOR(host_client->edict, ED_v_angle)); + VectorCopy(angle, ED_Vector(host_client->edict, ED_v_angle)); // read movement move->forwardmove = MSG_ReadShort(); @@ -466,12 +466,12 @@ void SV_ReadClientMove(usercmd_t *move) // read buttons bits = MSG_ReadByte(); - ED_FLOAT(host_client->edict, ED_button0) = bits & 1; - ED_FLOAT(host_client->edict, ED_button2) = (bits & 2) >> 1; + ED_Float(host_client->edict, ED_button0) = bits & 1; + ED_Float(host_client->edict, ED_button2) = (bits & 2) >> 1; i = MSG_ReadByte(); if(i) - ED_FLOAT(host_client->edict, ED_impulse) = i; + ED_Float(host_client->edict, ED_impulse) = i; } /* diff --git a/source/unix/net_udp.c b/source/unix/net_udp.c index 5c69200..03979e7 100644 --- a/source/unix/net_udp.c +++ b/source/unix/net_udp.c @@ -348,7 +348,7 @@ const char *UDP_AddrToString(struct qsockaddr *addr) int32_t haddr; haddr = ntohl(((struct sockaddr_in *)addr)->sin_addr.s_addr); - q_snprintf(buffer, sizeof(buffer), "%" PRIi32 ".%" PRIi32 ".%" PRIi32 ".%" PRIi32 ":%" PRIi32 "", (haddr >> 24) & 0xff, + q_snprintf(buffer, sizeof(buffer), "%" PRIi32 ".%" PRIi32 ".%" PRIi32 ".%" PRIi32 ":%" PRIi32, (haddr >> 24) & 0xff, (haddr >> 16) & 0xff, (haddr >> 8) & 0xff, haddr & 0xff, ntohs(((struct sockaddr_in *)addr)->sin_port)); return buffer; @@ -360,7 +360,7 @@ int32_t UDP_StringToAddr(const char *string, struct qsockaddr *addr) { int32_t ha1, ha2, ha3, ha4, hp, ipaddr; - sscanf(string, "%" PRIi32 ".%" PRIi32 ".%" PRIi32 ".%" PRIi32 ":%" PRIi32 "", &ha1, &ha2, &ha3, &ha4, &hp); + sscanf(string, "%" PRIi32 ".%" PRIi32 ".%" PRIi32 ".%" PRIi32 ":%" PRIi32, &ha1, &ha2, &ha3, &ha4, &hp); ipaddr = (ha1 << 24) | (ha2 << 16) | (ha3 << 8) | ha4; addr->qsa_family = AF_INET; diff --git a/source/wad.c b/source/wad.c index 928975e..6ce01d5 100644 --- a/source/wad.c +++ b/source/wad.c @@ -145,7 +145,7 @@ void *W_GetLumpNum(int32_t num) lumpinfo_t *lump; if(num < 0 || num > wad_numlumps) - Sys_Error("W_GetLumpNum: bad number: %" PRIi32 "", num); + Sys_Error("W_GetLumpNum: bad number: %" PRIi32, num); lump = wad_lumps + num; diff --git a/source/windows/net_wins.c b/source/windows/net_wins.c index b0f478e..a301bb7 100644 --- a/source/windows/net_wins.c +++ b/source/windows/net_wins.c @@ -107,7 +107,7 @@ static void WINS_GetLocalAddress(void) myAddr = *(in_addr_t *)local->h_addr_list[0]; addr = ntohl(myAddr); - sprintf(my_tcpip_address, "%" PRIi64 ".%" PRIi64 ".%" PRIi64 ".%" PRIi64 "", (addr >> 24) & 0xff, (addr >> 16) & 0xff, (addr >> 8) & 0xff, addr & 0xff); + sprintf(my_tcpip_address, "%" PRIi64 ".%" PRIi64 ".%" PRIi64 ".%" PRIi64, (addr >> 24) & 0xff, (addr >> 16) & 0xff, (addr >> 8) & 0xff, addr & 0xff); } @@ -430,7 +430,7 @@ const char *WINS_AddrToString(struct qsockaddr *addr) int32_t haddr; haddr = ntohl(((struct sockaddr_in *)addr)->sin_addr.s_addr); - sprintf(buffer, "%" PRIi32 ".%" PRIi32 ".%" PRIi32 ".%" PRIi32 ":%" PRIi32 "", (haddr >> 24) & 0xff, + sprintf(buffer, "%" PRIi32 ".%" PRIi32 ".%" PRIi32 ".%" PRIi32 ":%" PRIi32, (haddr >> 24) & 0xff, (haddr >> 16) & 0xff, (haddr >> 8) & 0xff, haddr & 0xff, ntohs(((struct sockaddr_in *)addr)->sin_port)); return buffer; @@ -442,7 +442,7 @@ int32_t WINS_StringToAddr(const char *string, struct qsockaddr *addr) { int32_t ha1, ha2, ha3, ha4, hp, ipaddr; - sscanf(string, "%" PRIi32 ".%" PRIi32 ".%" PRIi32 ".%" PRIi32 ":%" PRIi32 "", &ha1, &ha2, &ha3, &ha4, &hp); + sscanf(string, "%" PRIi32 ".%" PRIi32 ".%" PRIi32 ".%" PRIi32 ":%" PRIi32, &ha1, &ha2, &ha3, &ha4, &hp); ipaddr = (ha1 << 24) | (ha2 << 16) | (ha3 << 8) | ha4; addr->qsa_family = AF_INET; diff --git a/source/windows/net_wipx.c b/source/windows/net_wipx.c index 2b1e973..6abeb88 100644 --- a/source/windows/net_wipx.c +++ b/source/windows/net_wipx.c @@ -303,7 +303,7 @@ const char *WIPX_AddrToString(struct qsockaddr *addr) { static char buf[28]; - sprintf(buf, "%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x:%" PRIu32 "", + sprintf(buf, "%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x:%" PRIu32, ((struct sockaddr_ipx *)addr)->sa_netnum[0] & 0xff, ((struct sockaddr_ipx *)addr)->sa_netnum[1] & 0xff, ((struct sockaddr_ipx *)addr)->sa_netnum[2] & 0xff, @@ -350,7 +350,7 @@ int32_t WIPX_StringToAddr(const char *string, struct qsockaddr *addr) DO(19, sa_nodenum[5]); #undef DO - sscanf(&string[22], "%" PRIu32 "", &val); + sscanf(&string[22], "%" PRIu32, &val); ((struct sockaddr_ipx *)addr)->sa_socket = htons((uint16_t)val); return 0; @@ -393,12 +393,12 @@ int32_t WIPX_GetAddrFromName(const char *name, struct qsockaddr *addr) if(n == 12) { - sprintf(buf, "00000000:%s:%" PRIu32 "", name, net_hostport); + sprintf(buf, "00000000:%s:%" PRIu32, name, net_hostport); return WIPX_StringToAddr(buf, addr); } if(n == 21) { - sprintf(buf, "%s:%" PRIu32 "", name, net_hostport); + sprintf(buf, "%s:%" PRIu32, name, net_hostport); return WIPX_StringToAddr(buf, addr); } if(n > 21 && n <= 27) diff --git a/source/world.c b/source/world.c index dac5525..074bbbd 100644 --- a/source/world.c +++ b/source/world.c @@ -137,18 +137,18 @@ hull_t *SV_HullForEntity(edict_t *ent, vec3_t mins, vec3_t maxs, vec3_t offset) hull_t *hull; // decide which clipping hull to use, based on the size - if(ED_FLOAT(ent, ED_solid) == SOLID_BSP) + if(ED_Float(ent, ED_solid) == SOLID_BSP) { // explicit hulls in the BSP model - if(ED_FLOAT(ent, ED_movetype) != MOVETYPE_PUSH) + if(ED_Float(ent, ED_movetype) != MOVETYPE_PUSH) Host_Error("SOLID_BSP without MOVETYPE_PUSH (%s at %f %f %f)", - ED_STRING(ent, ED_classname), ED_VECTOR(ent, ED_origin)[0], ED_VECTOR(ent, ED_origin)[1], ED_VECTOR(ent, ED_origin)[2]); + ED_String(ent, ED_classname), ED_Vector(ent, ED_origin)[0], ED_Vector(ent, ED_origin)[1], ED_Vector(ent, ED_origin)[2]); - model = sv.models[(int32_t)ED_FLOAT(ent, ED_modelindex) ]; + model = sv.models[(int32_t)ED_Float(ent, ED_modelindex) ]; if(!model || model->type != mod_brush) Host_Error("SOLID_BSP with a non bsp model (%s at %f %f %f)", - ED_STRING(ent, ED_classname), ED_VECTOR(ent, ED_origin)[0], ED_VECTOR(ent, ED_origin)[1], ED_VECTOR(ent, ED_origin)[2]); + ED_String(ent, ED_classname), ED_Vector(ent, ED_origin)[0], ED_Vector(ent, ED_origin)[1], ED_Vector(ent, ED_origin)[2]); VectorSubtract(maxs, mins, size); if(size[0] < 3) @@ -160,17 +160,17 @@ hull_t *SV_HullForEntity(edict_t *ent, vec3_t mins, vec3_t maxs, vec3_t offset) // calculate an offset value to center the origin VectorSubtract(hull->clip_mins, mins, offset); - VectorAdd(offset, ED_VECTOR(ent, ED_origin), offset); + VectorAdd(offset, ED_Vector(ent, ED_origin), offset); } else { // create a temp hull from bounding box sizes - VectorSubtract(ED_VECTOR(ent, ED_mins), maxs, hullmins); - VectorSubtract(ED_VECTOR(ent, ED_maxs), mins, hullmaxs); + VectorSubtract(ED_Vector(ent, ED_mins), maxs, hullmins); + VectorSubtract(ED_Vector(ent, ED_maxs), mins, hullmaxs); hull = SV_HullForBox(hullmins, hullmaxs); - VectorCopy(ED_VECTOR(ent, ED_origin), offset); + VectorCopy(ED_Vector(ent, ED_origin), offset); } @@ -297,14 +297,14 @@ SV_AreaTriggerEdicts(edict_t *ent, areanode_t *node, edict_t **list, int32_t *li touch = EDICT_FROM_AREA(l); if(touch == ent) continue; - if(!ED_FUNC(touch, ED_touch) || ED_FLOAT(touch, ED_solid) != SOLID_TRIGGER) + if(!ED_Func(touch, ED_touch) || ED_Float(touch, ED_solid) != SOLID_TRIGGER) continue; - if(ED_VECTOR(ent, ED_absmin)[0] > ED_VECTOR(touch, ED_absmax)[0] - || ED_VECTOR(ent, ED_absmin)[1] > ED_VECTOR(touch, ED_absmax)[1] - || ED_VECTOR(ent, ED_absmin)[2] > ED_VECTOR(touch, ED_absmax)[2] - || ED_VECTOR(ent, ED_absmax)[0] < ED_VECTOR(touch, ED_absmin)[0] - || ED_VECTOR(ent, ED_absmax)[1] < ED_VECTOR(touch, ED_absmin)[1] - || ED_VECTOR(ent, ED_absmax)[2] < ED_VECTOR(touch, ED_absmin)[2]) + if(ED_Vector(ent, ED_absmin)[0] > ED_Vector(touch, ED_absmax)[0] + || ED_Vector(ent, ED_absmin)[1] > ED_Vector(touch, ED_absmax)[1] + || ED_Vector(ent, ED_absmin)[2] > ED_Vector(touch, ED_absmax)[2] + || ED_Vector(ent, ED_absmax)[0] < ED_Vector(touch, ED_absmin)[0] + || ED_Vector(ent, ED_absmax)[1] < ED_Vector(touch, ED_absmin)[1] + || ED_Vector(ent, ED_absmax)[2] < ED_Vector(touch, ED_absmin)[2]) continue; if(*listcount == listspace) @@ -318,9 +318,9 @@ SV_AreaTriggerEdicts(edict_t *ent, areanode_t *node, edict_t **list, int32_t *li if(node->axis == -1) return; - if(ED_VECTOR(ent, ED_absmax)[node->axis] > node->dist) + if(ED_Vector(ent, ED_absmax)[node->axis] > node->dist) SV_AreaTriggerEdicts(ent, node->children[0], list, listcount, listspace); - if(ED_VECTOR(ent, ED_absmin)[node->axis] < node->dist) + if(ED_Vector(ent, ED_absmin)[node->axis] < node->dist) SV_AreaTriggerEdicts(ent, node->children[1], list, listcount, listspace); } @@ -355,25 +355,25 @@ void SV_TouchLinks(edict_t *ent) // edicts later in the list no longer touch if(touch == ent) continue; - if(!ED_FUNC(touch, ED_touch) || ED_FLOAT(touch, ED_solid) != SOLID_TRIGGER) + if(!ED_Func(touch, ED_touch) || ED_Float(touch, ED_solid) != SOLID_TRIGGER) continue; - if(ED_VECTOR(ent, ED_absmin)[0] > ED_VECTOR(touch, ED_absmax)[0] - || ED_VECTOR(ent, ED_absmin)[1] > ED_VECTOR(touch, ED_absmax)[1] - || ED_VECTOR(ent, ED_absmin)[2] > ED_VECTOR(touch, ED_absmax)[2] - || ED_VECTOR(ent, ED_absmax)[0] < ED_VECTOR(touch, ED_absmin)[0] - || ED_VECTOR(ent, ED_absmax)[1] < ED_VECTOR(touch, ED_absmin)[1] - || ED_VECTOR(ent, ED_absmax)[2] < ED_VECTOR(touch, ED_absmin)[2]) + if(ED_Vector(ent, ED_absmin)[0] > ED_Vector(touch, ED_absmax)[0] + || ED_Vector(ent, ED_absmin)[1] > ED_Vector(touch, ED_absmax)[1] + || ED_Vector(ent, ED_absmin)[2] > ED_Vector(touch, ED_absmax)[2] + || ED_Vector(ent, ED_absmax)[0] < ED_Vector(touch, ED_absmin)[0] + || ED_Vector(ent, ED_absmax)[1] < ED_Vector(touch, ED_absmin)[1] + || ED_Vector(ent, ED_absmax)[2] < ED_Vector(touch, ED_absmin)[2]) continue; - old_self = G_PEDICT(GBL_self); - old_other = G_PEDICT(GBL_other); + old_self = G_PEdict(GBL_self); + old_other = G_PEdict(GBL_other); - G_PEDICT(GBL_self) = EDICT_TO_PROG(touch); - G_PEDICT(GBL_other) = EDICT_TO_PROG(ent); - G_FLOAT(GBL_time) = sv.time; - PR_ExecuteProgram(ED_FUNC(touch, ED_touch)); + G_PEdict(GBL_self) = EdictProg(touch); + G_PEdict(GBL_other) = EdictProg(ent); + G_Float(GBL_time) = sv.time; + PR_ExecuteProgram(ED_Func(touch, ED_touch)); - G_PEDICT(GBL_self) = old_self; - G_PEDICT(GBL_other) = old_other; + G_PEdict(GBL_self) = old_self; + G_PEdict(GBL_other) = old_other; } // free hunk-allocated edicts array @@ -415,7 +415,7 @@ void SV_FindTouchedLeafs(edict_t *ent, mnode_t *node) // NODE_MIXED splitplane = node->plane; - sides = BOX_ON_PLANE_SIDE(ED_VECTOR(ent, ED_absmin), ED_VECTOR(ent, ED_absmax), splitplane); + sides = BOX_ON_PLANE_SIDE(ED_Vector(ent, ED_absmin), ED_Vector(ent, ED_absmax), splitplane); // recurse down the contacted sides if(sides & 1) @@ -445,38 +445,38 @@ void SV_LinkEdict(edict_t *ent, bool touch_triggers) return; // set the abs box - VectorAdd(ED_VECTOR(ent, ED_origin), ED_VECTOR(ent, ED_mins), ED_VECTOR(ent, ED_absmin)); - VectorAdd(ED_VECTOR(ent, ED_origin), ED_VECTOR(ent, ED_maxs), ED_VECTOR(ent, ED_absmax)); + VectorAdd(ED_Vector(ent, ED_origin), ED_Vector(ent, ED_mins), ED_Vector(ent, ED_absmin)); + VectorAdd(ED_Vector(ent, ED_origin), ED_Vector(ent, ED_maxs), ED_Vector(ent, ED_absmax)); // // to make items easier to pick up and allow them to be grabbed off // of shelves, the abs sizes are expanded // - if((int32_t)ED_FLOAT(ent, ED_flags) & FL_ITEM) + if((int32_t)ED_Float(ent, ED_flags) & FL_ITEM) { - ED_VECTOR(ent, ED_absmin)[0] -= 15; - ED_VECTOR(ent, ED_absmin)[1] -= 15; - ED_VECTOR(ent, ED_absmax)[0] += 15; - ED_VECTOR(ent, ED_absmax)[1] += 15; + ED_Vector(ent, ED_absmin)[0] -= 15; + ED_Vector(ent, ED_absmin)[1] -= 15; + ED_Vector(ent, ED_absmax)[0] += 15; + ED_Vector(ent, ED_absmax)[1] += 15; } else { // because movement is clipped an epsilon away from an actual edge, // we must fully check even when bounding boxes don't quite touch - ED_VECTOR(ent, ED_absmin)[0] -= 1; - ED_VECTOR(ent, ED_absmin)[1] -= 1; - ED_VECTOR(ent, ED_absmin)[2] -= 1; - ED_VECTOR(ent, ED_absmax)[0] += 1; - ED_VECTOR(ent, ED_absmax)[1] += 1; - ED_VECTOR(ent, ED_absmax)[2] += 1; + ED_Vector(ent, ED_absmin)[0] -= 1; + ED_Vector(ent, ED_absmin)[1] -= 1; + ED_Vector(ent, ED_absmin)[2] -= 1; + ED_Vector(ent, ED_absmax)[0] += 1; + ED_Vector(ent, ED_absmax)[1] += 1; + ED_Vector(ent, ED_absmax)[2] += 1; } // link to PVS leafs ent->num_leafs = 0; - if(ED_FLOAT(ent, ED_modelindex)) + if(ED_Float(ent, ED_modelindex)) SV_FindTouchedLeafs(ent, sv.worldmodel->nodes); - if(ED_FLOAT(ent, ED_solid) == SOLID_NOT) + if(ED_Float(ent, ED_solid) == SOLID_NOT) return; // find the first node that the ent's box crosses @@ -485,9 +485,9 @@ void SV_LinkEdict(edict_t *ent, bool touch_triggers) { if(node->axis == -1) break; - if(ED_VECTOR(ent, ED_absmin)[node->axis] > node->dist) + if(ED_Vector(ent, ED_absmin)[node->axis] > node->dist) node = node->children[0]; - else if(ED_VECTOR(ent, ED_absmax)[node->axis] < node->dist) + else if(ED_Vector(ent, ED_absmax)[node->axis] < node->dist) node = node->children[1]; else break; // crosses the node @@ -495,7 +495,7 @@ void SV_LinkEdict(edict_t *ent, bool touch_triggers) // link it in - if(ED_FLOAT(ent, ED_solid) == SOLID_TRIGGER) + if(ED_Float(ent, ED_solid) == SOLID_TRIGGER) InsertLinkBefore(&ent->area, &node->trigger_edicts); else InsertLinkBefore(&ent->area, &node->solid_edicts); @@ -583,7 +583,7 @@ edict_t *SV_TestEntityPosition(edict_t *ent) { trace_t trace; - trace = SV_Move(ED_VECTOR(ent, ED_origin), ED_VECTOR(ent, ED_mins), ED_VECTOR(ent, ED_maxs), ED_VECTOR(ent, ED_origin), 0, ent); + trace = SV_Move(ED_Vector(ent, ED_origin), ED_Vector(ent, ED_mins), ED_Vector(ent, ED_maxs), ED_Vector(ent, ED_origin), 0, ent); if(trace.startsolid) return sv.edicts; @@ -794,25 +794,25 @@ void SV_ClipToLinks(areanode_t *node, moveclip_t *clip) { next = l->next; touch = EDICT_FROM_AREA(l); - if(ED_FLOAT(touch, ED_solid) == SOLID_NOT) + if(ED_Float(touch, ED_solid) == SOLID_NOT) continue; if(touch == clip->passedict) continue; - if(ED_FLOAT(touch, ED_solid) == SOLID_TRIGGER) + if(ED_Float(touch, ED_solid) == SOLID_TRIGGER) Sys_Error("Trigger in clipping list"); - if(clip->type == MOVE_NOMONSTERS && ED_FLOAT(touch, ED_solid) != SOLID_BSP) + if(clip->type == MOVE_NOMONSTERS && ED_Float(touch, ED_solid) != SOLID_BSP) continue; - if(clip->boxmins[0] > ED_VECTOR(touch, ED_absmax)[0] - || clip->boxmins[1] > ED_VECTOR(touch, ED_absmax)[1] - || clip->boxmins[2] > ED_VECTOR(touch, ED_absmax)[2] - || clip->boxmaxs[0] < ED_VECTOR(touch, ED_absmin)[0] - || clip->boxmaxs[1] < ED_VECTOR(touch, ED_absmin)[1] - || clip->boxmaxs[2] < ED_VECTOR(touch, ED_absmin)[2]) + if(clip->boxmins[0] > ED_Vector(touch, ED_absmax)[0] + || clip->boxmins[1] > ED_Vector(touch, ED_absmax)[1] + || clip->boxmins[2] > ED_Vector(touch, ED_absmax)[2] + || clip->boxmaxs[0] < ED_Vector(touch, ED_absmin)[0] + || clip->boxmaxs[1] < ED_Vector(touch, ED_absmin)[1] + || clip->boxmaxs[2] < ED_Vector(touch, ED_absmin)[2]) continue; - if(clip->passedict && ED_VECTOR(clip->passedict, ED_size)[0] && !ED_VECTOR(touch, ED_size)[0]) + if(clip->passedict && ED_Vector(clip->passedict, ED_size)[0] && !ED_Vector(touch, ED_size)[0]) continue; // points never interact // might intersect, so do an exact clip @@ -820,13 +820,13 @@ void SV_ClipToLinks(areanode_t *node, moveclip_t *clip) return; if(clip->passedict) { - if(PROG_TO_EDICT(ED_PEDICT(touch, ED_owner)) == clip->passedict) + if(ProgEdict(ED_PEdict(touch, ED_owner)) == clip->passedict) continue; // don't clip against own missiles - if(PROG_TO_EDICT(ED_PEDICT(clip->passedict, ED_owner)) == touch) + if(ProgEdict(ED_PEdict(clip->passedict, ED_owner)) == touch) continue; // don't clip against owner } - if((int32_t)ED_FLOAT(touch, ED_flags) & FL_MONSTER) + if((int32_t)ED_Float(touch, ED_flags) & FL_MONSTER) trace = SV_ClipMoveToEntity(touch, clip->start, clip->mins2, clip->maxs2, clip->end); else trace = SV_ClipMoveToEntity(touch, clip->start, clip->mins, clip->maxs, clip->end); diff --git a/source/world.h b/source/world.h index 5a9ebdd..0ef89f8 100644 --- a/source/world.h +++ b/source/world.h @@ -57,7 +57,7 @@ void SV_UnlinkEdict(edict_t *ent); void SV_LinkEdict(edict_t *ent, bool touch_triggers); // Needs to be called any time an entity changes origin, mins, maxs, or solid // flags ent->v.modified -// sets ED_VECTOR(ent, ED_absmin) and ED_VECTOR(ent, ED_absmax) +// sets ED_Vector(ent, ED_absmin) and ED_Vector(ent, ED_absmax) // if touchtriggers, calls prog functions for the intersected triggers int32_t SV_PointContents(vec3_t p); diff --git a/source/zone.c b/source/zone.c index c908e25..f6156ab 100644 --- a/source/zone.c +++ b/source/zone.c @@ -438,7 +438,7 @@ void *Hunk_AllocName(int32_t size, const char *name) #endif if(size < 0) - Sys_Error("Hunk_AllocName: bad size: %" PRIi32 "", size); + Sys_Error("Hunk_AllocName: bad size: %" PRIi32, size); size = sizeof(hunk_t) + ((size + 15) & ~15); @@ -467,7 +467,7 @@ int32_t Hunk_LowMark(void) void Hunk_FreeToLowMark(int32_t mark) { if(mark < 0 || mark > hunk_low_used) - Sys_Error("Hunk_FreeToLowMark: bad mark %" PRIi32 "", mark); + Sys_Error("Hunk_FreeToLowMark: bad mark %" PRIi32, mark); memset(hunk_base + mark, 0, hunk_low_used - mark); hunk_low_used = mark; } @@ -491,7 +491,7 @@ void Hunk_FreeToHighMark(int32_t mark) Hunk_FreeToHighMark(hunk_tempmark); } if(mark < 0 || mark > hunk_high_used) - Sys_Error("Hunk_FreeToHighMark: bad mark %" PRIi32 "", mark); + Sys_Error("Hunk_FreeToHighMark: bad mark %" PRIi32, mark); memset(hunk_base + hunk_size - hunk_high_used, 0, hunk_high_used - mark); hunk_high_used = mark; } @@ -507,7 +507,7 @@ void *Hunk_HighAllocName(int32_t size, const char *name) hunk_t *h; if(size < 0) - Sys_Error("Hunk_HighAllocName: bad size: %" PRIi32 "", size); + Sys_Error("Hunk_HighAllocName: bad size: %" PRIi32, size); if(hunk_tempactive) { @@ -909,7 +909,7 @@ void *Cache_Alloc(cache_user_t *c, int32_t size, const char *name) Sys_Error("Cache_Alloc: allready allocated"); if(size <= 0) - Sys_Error("Cache_Alloc: size %" PRIi32 "", size); + Sys_Error("Cache_Alloc: size %" PRIi32, size); size = (size + sizeof(cache_system_t) + 15) & ~15;