From 61e4aa96b32ecbd46562d22af8deb1e928b87d7f Mon Sep 17 00:00:00 2001 From: Spoike Date: Wed, 29 Jun 2011 18:39:11 +0000 Subject: [PATCH] removed separate trigger/solid links. some q3 fixes. q2 will autosave on map changes, like q2 normally does. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@3839 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/cl_cam.c | 30 - engine/client/cl_cg.c | 61 +- engine/client/cl_demo.c | 2 +- engine/client/cl_ents.c | 4 +- engine/client/cl_ui.c | 21 - engine/client/clhl_game.c | 9 - engine/client/client.h | 2 +- engine/client/clq2_ents.c | 180 +---- engine/client/clq3_parse.c | 9 +- engine/client/m_mp3.c | 22 +- engine/client/m_options.c | 2 +- engine/client/m_single.c | 6 +- engine/client/p_classic.c | 41 +- engine/client/p_script.c | 3 + engine/client/renderer.c | 2 +- engine/client/sbar.c | 2 +- engine/client/sys_linux.c | 3 +- engine/client/sys_plugfte.c | 2 +- engine/client/view.c | 1 - engine/common/bothdefs.h | 4 + engine/common/bspfile.h | 5 + engine/common/common.c | 34 +- engine/common/common.h | 41 +- engine/common/crc.c | 4 +- engine/common/fs.c | 10 +- engine/common/gl_q2bsp.c | 11 +- engine/common/mathlib.c | 36 +- engine/common/mathlib.h | 6 +- engine/common/pmovetst.c | 2 +- engine/common/protocol.h | 5 +- engine/common/q1bsp.c | 10 +- engine/common/q3common.c | 14 +- engine/common/world.h | 3 +- engine/common/zone.c | 2 +- engine/dotnet2005/botlib.vcproj | 407 +++++++++++ engine/dotnet2005/ftequake.sln | 43 +- engine/dotnet2005/ftequake.vcproj | 1052 +++++++++++++++-------------- engine/gl/gl_font.c | 2 +- engine/gl/gl_model.c | 5 +- engine/gl/gl_model.h | 4 +- engine/gl/gl_rlight.c | 2 +- engine/gl/gl_shader.c | 4 +- engine/gl/gl_warp.c | 1 - engine/server/pr_cmds.c | 5 +- engine/server/pr_q1qvm.c | 28 +- engine/server/savegame.c | 13 +- engine/server/server.h | 1 + engine/server/sv_ccmds.c | 17 + engine/server/sv_ents.c | 12 +- engine/server/sv_phys.c | 2 +- engine/server/sv_user.c | 10 +- engine/server/svmodel.c | 5 +- engine/server/svq3_game.c | 21 +- engine/server/world.c | 123 +--- 54 files changed, 1346 insertions(+), 1000 deletions(-) create mode 100644 engine/dotnet2005/botlib.vcproj diff --git a/engine/client/cl_cam.c b/engine/client/cl_cam.c index 4ce9a0c43..ff6acccfc 100644 --- a/engine/client/cl_cam.c +++ b/engine/client/cl_cam.c @@ -60,36 +60,6 @@ int autocam[MAX_SPLITS]; int selfcam=1; -void vectoangles(vec3_t vec, vec3_t ang) -{ - float forward; - float yaw, pitch; - - if (vec[1] == 0 && vec[0] == 0) - { - yaw = 0; - if (vec[2] > 0) - pitch = 90; - else - pitch = 270; - } - else - { - yaw = /*(int)*/ (atan2(vec[1], vec[0]) * 180 / M_PI); - if (yaw < 0) - yaw += 360; - - forward = sqrt (vec[0]*vec[0] + vec[1]*vec[1]); - pitch = /*(int)*/ (atan2(vec[2], forward) * 180 / M_PI); - if (pitch < 0) - pitch += 360; - } - - ang[0] = pitch; - ang[1] = yaw; - ang[2] = 0; -} - static float vlen(vec3_t v) { return sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); diff --git a/engine/client/cl_cg.c b/engine/client/cl_cg.c index b486f1ec3..7eff14936 100644 --- a/engine/client/cl_cg.c +++ b/engine/client/cl_cg.c @@ -32,6 +32,8 @@ extern int mod_numknown; #define VM_FROMSHANDLE(a) (a?r_shaders+a-1:NULL) #define VM_TOSHANDLE(a) (a?a-r_shaders+1:0) +extern model_t box_model; + typedef enum { CG_PRINT, CG_ERROR, @@ -560,9 +562,12 @@ static qintptr_t CG_SystemCalls(void *offset, quintptr_t mask, qintptr_t fn, con case CG_CM_POINTCONTENTS: //int trap_CM_PointContents( const vec3_t p, clipHandle_t model ); { unsigned int pc; - model_t *mod = VM_FROMMHANDLE(arg[1]); - if (!mod) - mod = cl.worldmodel; + unsigned int modhandle = VM_LONG(arg[1]); + model_t *mod; + if (modhandle >= MAX_MODELS) + mod = &box_model; + else + mod = cl.model_precache[modhandle+1]; if (mod) pc = cl.worldmodel->funcs.NativeContents(mod, 0, 0, NULL, VM_POINTER(arg[0]), vec3_origin, vec3_origin); else @@ -575,12 +580,14 @@ static qintptr_t CG_SystemCalls(void *offset, quintptr_t mask, qintptr_t fn, con { unsigned int pc; float *p = VM_POINTER(arg[0]); - model_t *mod = VM_FROMMHANDLE(arg[1]); + unsigned int modhandle = VM_LONG(arg[1]); float *origin = VM_POINTER(arg[2]); float *angles = VM_POINTER(arg[3]); - - if (!mod) - mod = cl.worldmodel; + model_t *mod; + if (modhandle >= MAX_MODELS) + mod = &box_model; + else + mod = cl.model_precache[modhandle+1]; if (mod) { @@ -618,12 +625,16 @@ static qintptr_t CG_SystemCalls(void *offset, quintptr_t mask, qintptr_t fn, con float *end = VM_POINTER(arg[2]); float *mins = VM_POINTER(arg[3]); float *maxs = VM_POINTER(arg[4]); - model_t *mod = VM_FROMMHANDLE(arg[5]); - int brushmask = VM_LONG(arg[6]); + unsigned int modhandle = VM_LONG(arg[5]); + int brushmask = VM_LONG(arg[6]); float *origin = VM_POINTER(arg[7]); float *angles = VM_POINTER(arg[8]); - if (!mod) - mod = cl.worldmodel; + model_t *mod; + if (modhandle >= MAX_MODELS) + mod = &box_model; + else + mod = cl.model_precache[modhandle+1]; + if (!mins) mins = vec3_origin; if (!maxs) @@ -673,24 +684,19 @@ static qintptr_t CG_SystemCalls(void *offset, quintptr_t mask, qintptr_t fn, con float *end = VM_POINTER(arg[2]); float *mins = VM_POINTER(arg[3]); float *maxs = VM_POINTER(arg[4]); - model_t *mod = VM_FROMMHANDLE(arg[5]); + unsigned int modhandle = VM_LONG(arg[5]); int brushmask = VM_LONG(arg[6]); - if (!mod) - mod = cl.worldmodel; + model_t *mod; + if (modhandle >= MAX_MODELS) + mod = &box_model; + else + mod = cl.model_precache[modhandle+1]; + if (!mins) mins = vec3_origin; if (!maxs) maxs = vec3_origin; - if (mod) - { - mod->funcs.NativeTrace(mod, 0, 0, NULL, start, end, mins, maxs, brushmask, &tr); - } - else - { - memset(&tr, 0, sizeof(tr)); - tr.allsolid = tr.startsolid = true; - tr.contents = 1; - } + mod->funcs.NativeTrace(mod, 0, 0, NULL, start, end, mins, maxs, brushmask, &tr); results->allsolid = tr.allsolid; results->contents = tr.contents; results->fraction = tr.fraction; @@ -724,14 +730,17 @@ static qintptr_t CG_SystemCalls(void *offset, quintptr_t mask, qintptr_t fn, con break; case CG_CM_INLINEMODEL: - VM_LONG(ret) = VM_TOMHANDLE(cl.model_precache[VM_LONG(arg[0])+1]); + if ((unsigned int)VM_LONG(arg[0]) > (cl.worldmodel?cl.worldmodel->numsubmodels:0)) + Host_EndGame("cgame asked for invalid model number\n"); + VM_LONG(ret) = VM_LONG(arg[0]); break; case CG_CM_NUMINLINEMODELS: VM_LONG(ret) = cl.worldmodel?cl.worldmodel->numsubmodels:0; break; case CG_CM_TEMPBOXMODEL: - VM_LONG(ret) = VM_TOMHANDLE(CM_TempBoxModel(VM_POINTER(arg[0]), VM_POINTER(arg[1]))); + CM_TempBoxModel(VM_POINTER(arg[0]), VM_POINTER(arg[1])); + VM_LONG(ret) = MAX_MODELS; break; case CG_R_MODELBOUNDS: diff --git a/engine/client/cl_demo.c b/engine/client/cl_demo.c index 0cc4810d0..1bde7fb22 100644 --- a/engine/client/cl_demo.c +++ b/engine/client/cl_demo.c @@ -167,7 +167,7 @@ int demo_preparsedemo(unsigned char *buffer, int bytes) switch(buffer[1]&dem_mask) { case dem_cmd: - ofs = -(sizeof(q1usercmd_t)); + ofs = -(int)(sizeof(q1usercmd_t)); ofs = 0; break; case dem_set: diff --git a/engine/client/cl_ents.c b/engine/client/cl_ents.c index e29ffafd5..88fb20885 100644 --- a/engine/client/cl_ents.c +++ b/engine/client/cl_ents.c @@ -1356,7 +1356,7 @@ entity_t *V_AddEntity(entity_t *in) return ent; } - +/* void VQ2_AddLerpEntity(entity_t *in) //a convienience function { entity_t *ent; @@ -1384,7 +1384,7 @@ void VQ2_AddLerpEntity(entity_t *in) //a convienience function VectorInverse(ent->axis[1]); ent->angles[0]*=-1; } - +*/ int V_AddLight (int entsource, vec3_t org, float quant, float r, float g, float b) { return CL_NewDlightRGB (entsource, org, quant, -0.1, r, g, b) - cl_dlights; diff --git a/engine/client/cl_ui.c b/engine/client/cl_ui.c index 658569dc9..82a04145a 100644 --- a/engine/client/cl_ui.c +++ b/engine/client/cl_ui.c @@ -7,15 +7,6 @@ int keycatcher; -#define MAX_TOKENLENGTH 1024 -typedef struct pc_token_s -{ - int type; - int subtype; - int intvalue; - float floatvalue; - char string[MAX_TOKENLENGTH]; -} pc_token_t; #define TT_STRING 1 // string #define TT_LITERAL 2 // literal #define TT_NUMBER 3 // number @@ -599,23 +590,11 @@ void VQ3_RenderView(const q3refdef_t *ref) } memcpy(cl.q2frame.areabits, ref->areamask, sizeof(cl.q2frame.areabits)); -#ifdef GLQUAKE - if (qrenderer == QR_OPENGL) - { - qglDisable(GL_ALPHA_TEST); - qglDisable(GL_BLEND); - } -#endif R_RenderView(); #ifdef GLQUAKE if (qrenderer == QR_OPENGL) { GL_Set2D (); - qglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - GL_TexEnv(GL_MODULATE); - - qglDisable(GL_ALPHA_TEST); - qglEnable(GL_BLEND); } #endif diff --git a/engine/client/clhl_game.c b/engine/client/clhl_game.c index 00cf99747..bfdc7525f 100644 --- a/engine/client/clhl_game.c +++ b/engine/client/clhl_game.c @@ -2,15 +2,6 @@ #include "glquake.h" #ifdef HLCLIENT - -//make shared -#ifndef QDECL - #ifdef _MSC_VER - #define QDECL _cdecl - #else - #define QDECL - #endif -#endif struct hlcvar_s *QDECL GHL_CVarGetPointer(char *varname); diff --git a/engine/client/client.h b/engine/client/client.h index 69c73f9fb..330965273 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -1094,7 +1094,7 @@ void Cam_TrackPlayer(int pnum, char *cmdname, char *plrarg); void Cam_Lock(int pnum, int playernum); void CL_InitCam(void); -void vectoangles(vec3_t vec, vec3_t ang); +void QDECL vectoangles(vec3_t vec, vec3_t ang); // //zqtp.c diff --git a/engine/client/clq2_ents.c b/engine/client/clq2_ents.c index 14dd66a69..0a4b3f174 100644 --- a/engine/client/clq2_ents.c +++ b/engine/client/clq2_ents.c @@ -504,164 +504,6 @@ FRAME PARSING ========================================================================= */ -#if 0 - -typedef struct -{ - int modelindex; - int num; // entity number - int effects; - vec3_t origin; - vec3_t oldorigin; - vec3_t angles; - qboolean present; -} projectile_t; - -#define MAX_PROJECTILES 64 -projectile_t cl_projectiles[MAX_PROJECTILES]; - -void CLQ2_ClearProjectiles (void) -{ - int i; - - for (i = 0; i < MAX_PROJECTILES; i++) { -// if (cl_projectiles[i].present) -// Com_DPrintf("PROJ: %d CLEARED\n", cl_projectiles[i].num); - cl_projectiles[i].present = false; - } -} - -/* -===================== -CL_ParseProjectiles - -Flechettes are passed as efficient temporary entities -===================== -*/ -void CLQ2_ParseProjectiles (void) -{ - int i, c, j; - byte bits[8]; - byte b; - projectile_t pr; - int lastempty = -1; - qboolean old = false; - - c = MSG_ReadByte (&net_message); - for (i=0 ; i>4) + (bits[2]<<4) ) <<1) - 4096; - pr.origin[2] = ( ( bits[3] + ((bits[4]&15)<<8) ) <<1) - 4096; - VectorCopy(pr.origin, pr.oldorigin); - - if (bits[4] & 64) - pr.effects = EF_BLASTER; - else - pr.effects = 0; - - if (bits[4] & 128) { - old = true; - bits[0] = MSG_ReadByte (&net_message); - bits[1] = MSG_ReadByte (&net_message); - bits[2] = MSG_ReadByte (&net_message); - bits[3] = MSG_ReadByte (&net_message); - bits[4] = MSG_ReadByte (&net_message); - pr.oldorigin[0] = ( ( bits[0] + ((bits[1]&15)<<8) ) <<1) - 4096; - pr.oldorigin[1] = ( ( (bits[1]>>4) + (bits[2]<<4) ) <<1) - 4096; - pr.oldorigin[2] = ( ( bits[3] + ((bits[4]&15)<<8) ) <<1) - 4096; - } - - bits[0] = MSG_ReadByte (&net_message); - bits[1] = MSG_ReadByte (&net_message); - bits[2] = MSG_ReadByte (&net_message); - - pr.angles[0] = 360*bits[0]/256; - pr.angles[1] = 360*bits[1]/256; - pr.modelindex = bits[2]; - - b = MSG_ReadByte (&net_message); - pr.num = (b & 0x7f); - if (b & 128) // extra entity number byte - pr.num |= (MSG_ReadByte (&net_message) << 7); - - pr.present = true; - - // find if this projectile already exists from previous frame - for (j = 0; j < MAX_PROJECTILES; j++) { - if (cl_projectiles[j].modelindex) { - if (cl_projectiles[j].num == pr.num) { - // already present, set up oldorigin for interpolation - if (!old) - VectorCopy(cl_projectiles[j].origin, pr.oldorigin); - cl_projectiles[j] = pr; - break; - } - } else - lastempty = j; - } - - // not present previous frame, add it - if (j == MAX_PROJECTILES) { - if (lastempty != -1) { - cl_projectiles[lastempty] = pr; - } - } - } -} - -/* -============= -CL_LinkProjectiles - -============= -*/ -void CLQ2_AddProjectiles (void) -{ - int i, j; - projectile_t *pr; - entity_t ent; - - memset (&ent, 0, sizeof(ent)); - - for (i=0, pr=cl_projectiles ; i < MAX_PROJECTILES ; i++, pr++) - { - // grab an entity to fill in - if (pr->modelindex < 1) - continue; - if (!pr->present) { - pr->modelindex = 0; - continue; // not present this frame (it was in the previous frame) - } - - ent.model = cl.model_draw[pr->modelindex]; - - // interpolate origin - for (j=0 ; j<3 ; j++) - { - ent.origin[j] = ent.oldorigin[j] = pr->oldorigin[j] + cl.lerpfrac * - (pr->origin[j] - pr->oldorigin[j]); - - } - - if (pr->effects & EF_BLASTER) - { - if (P_ParticleTrail(pr->oldorigin, ent.origin, rt_blastertrail, NULL)) - P_ParticleTrailIndex(pr->oldorigin, ent.origin, 0xe0, 1, NULL); - } - V_AddLight (pr->origin, 200, 0.2, 0.2, 0); - - VectorCopy (pr->angles, ent.angles); - VQ2_AddLerpEntity (&ent); - } -} -#endif - /* ================= CL_ParseEntityBits @@ -1333,6 +1175,7 @@ void CLQ2_AddPacketEntities (q2frame_t *frame) // q2clientinfo_t *ci; player_info_t *player; unsigned int effects, renderfx; + float back, fwds; // bonus items rotate at a fixed rate autorotate = anglemod(cl.time*100); @@ -1589,8 +1432,17 @@ void CLQ2_AddPacketEntities (q2frame_t *frame) } //pmm + /*lerp the ent now*/ + fwds = ent.framestate.g[FS_REG].lerpfrac; + back = 1 - ent.framestate.g[FS_REG].lerpfrac; + for (i = 0; i < 3; i++) + { + ent.origin[i] = ent.origin[i]*fwds + ent.oldorigin[i]*back; + } + ent.framestate.g[FS_REG].lerpfrac = back; + // add to refresh list - VQ2_AddLerpEntity (&ent); + V_AddEntity (&ent); // color shells generate a seperate entity for the main model @@ -1640,7 +1492,7 @@ void CLQ2_AddPacketEntities (q2frame_t *frame) ent.shaderRGBAf[1] = (!!(renderfx & Q2RF_SHELL_GREEN)); ent.shaderRGBAf[2] = (!!(renderfx & Q2RF_SHELL_BLUE)); ent.forcedshader = R_RegisterCustom("q2/shell", Shader_DefaultSkinShell, NULL); - VQ2_AddLerpEntity (&ent); + V_AddEntity (&ent); } ent.forcedshader = NULL; @@ -1694,7 +1546,7 @@ void CLQ2_AddPacketEntities (q2frame_t *frame) } */ // pmm - VQ2_AddLerpEntity (&ent); + V_AddEntity (&ent); //PGM - make sure these get reset. ent.flags = 0; @@ -1704,12 +1556,12 @@ void CLQ2_AddPacketEntities (q2frame_t *frame) if (s1->modelindex3) { ent.model = cl.model_precache[s1->modelindex3]; - VQ2_AddLerpEntity (&ent); + V_AddEntity (&ent); } if (s1->modelindex4) { ent.model = cl.model_precache[s1->modelindex4]; - VQ2_AddLerpEntity (&ent); + V_AddEntity (&ent); } if ( effects & Q2EF_POWERSCREEN ) @@ -1719,7 +1571,7 @@ void CLQ2_AddPacketEntities (q2frame_t *frame) ent.frame = 0; ent.flags |= (Q2RF_TRANSLUCENT | Q2RF_SHELL_GREEN); ent.alpha = 0.30; - VQ2_AddLerpEntity (&ent); + V_AddLerpEntity (&ent); */ } // add automatic particle trails diff --git a/engine/client/clq3_parse.c b/engine/client/clq3_parse.c index 2f4c83ef9..2f3d15738 100644 --- a/engine/client/clq3_parse.c +++ b/engine/client/clq3_parse.c @@ -518,6 +518,7 @@ void CLQ3_ParseGameState(void) int c; int index; char *configString; + cvar_t *cl_paused; // // wipe the client_state_t struct @@ -607,6 +608,10 @@ void CLQ3_ParseGameState(void) // load cgame, etc // CL_ChangeLevel(); + cl_paused = Cvar_FindVar("cl_paused"); + if (cl_paused && cl_paused->ival) + Cvar_ForceSet(cl_paused, "0"); + } #define TEXTCMD_BACKUP 64 @@ -716,7 +721,7 @@ qboolean CLQ3_Netchan_Process(void) msg_readcount = readcount; // calculate bitmask - bitmask = sequence ^ cls.challenge; + bitmask = (sequence ^ cls.challenge) & 0xff; string = ccs.clientCommands[lastClientCommandNum & TEXTCMD_MASK]; #ifndef Q3_NOENCRYPT @@ -767,7 +772,7 @@ void CL_Netchan_Transmit( int length, const qbyte *data ) lastServerCommandNum = MSG_ReadLong(); // calculate bitmask - bitmask = lastSequence ^ serverid ^ cls.challenge; + bitmask = (lastSequence ^ serverid ^ cls.challenge) & 0xff; string = ccs.serverCommands[lastServerCommandNum & TEXTCMD_MASK]; #ifndef Q3_NOENCRYPT diff --git a/engine/client/m_mp3.c b/engine/client/m_mp3.c index 6b6770ffe..ff0656c13 100644 --- a/engine/client/m_mp3.c +++ b/engine/client/m_mp3.c @@ -2258,7 +2258,8 @@ void Media_RecordFilm_f (void) BITMAPINFOHEADER bitmap_info_header; AVISTREAMINFO stream_header; FILE *f; - char filename[256]; + char aviname[256]; + char nativepath[256]; if (strlen(fourcc) == 4) recordavi_codec_fourcc = mmioFOURCC(*(fourcc+0), *(fourcc+1), *(fourcc+2), *(fourcc+3)); @@ -2271,23 +2272,24 @@ void Media_RecordFilm_f (void) AVIFileInit(); } - - snprintf(filename, sizeof(filename) - 5, "%s%s", com_quakedir, Cmd_Argv(1)); - COM_StripExtension(filename, filename, sizeof(filename)); - COM_DefaultExtension (filename, ".avi", sizeof(filename)); + /*convert to foo.avi*/ + COM_StripExtension(Cmd_Argv(1), aviname, sizeof(aviname)); + COM_DefaultExtension (aviname, ".avi", sizeof(aviname)); + /*find the system location of that*/ + FS_NativePath(aviname, FS_ROOT, nativepath, sizeof(nativepath)); //wipe it. - f = fopen(filename, "rb"); + f = fopen(nativepath, "rb"); if (f) { fclose(f); - unlink(filename); + unlink(nativepath); } - hr = AVIFileOpen(&recordavi_file, filename, OF_WRITE | OF_CREATE, NULL); + hr = AVIFileOpen(&recordavi_file, nativepath, OF_WRITE | OF_CREATE, NULL); if (FAILED(hr)) { - Con_Printf("Failed to open\n"); + Con_Printf("Failed to open %s\n", nativepath); return; } @@ -2312,7 +2314,7 @@ void Media_RecordFilm_f (void) hr = AVIFileCreateStream(recordavi_file, &recordavi_uncompressed_video_stream, &stream_header); if (FAILED(hr)) { - Con_Printf("Couldn't initialise the stream\n"); + Con_Printf("Couldn't initialise the stream, check codec\n"); Media_StopRecordFilm_f(); return; } diff --git a/engine/client/m_options.c b/engine/client/m_options.c index e2c8ab85e..9ca433eb5 100644 --- a/engine/client/m_options.c +++ b/engine/client/m_options.c @@ -1783,7 +1783,7 @@ qboolean M_Vid_GetMode(int num, int *w, int *h) v++; num--; } - if (v) + if (*v) { const char *c = *v; const char *s = strchr(c, 'x'); diff --git a/engine/client/m_single.c b/engine/client/m_single.c index 61af2b269..b02f8146e 100644 --- a/engine/client/m_single.c +++ b/engine/client/m_single.c @@ -150,9 +150,9 @@ void M_Menu_SinglePlayer_f (void) MC_AddCenterPicture(menu, 4, 24, "pics/m_banner_game"); menu->selecteditem = (menuoption_t*) - MC_AddConsoleCommand (menu, 64, 40, "Easy", "skill 0;deathmatch 0; coop 0;newgame\n"); - MC_AddConsoleCommand (menu, 64, 48, "Medium", "skill 1;deathmatch 0; coop 0;newgame\n"); - MC_AddConsoleCommand (menu, 64, 56, "Hard", "skill 2;deathmatch 0; coop 0;newgame\n"); + MC_AddConsoleCommand (menu, 64, 40, "Easy", "closemenu; skill 0;deathmatch 0; coop 0;newgame\n"); + MC_AddConsoleCommand (menu, 64, 48, "Medium", "closemenu; skill 1;deathmatch 0; coop 0;newgame\n"); + MC_AddConsoleCommand (menu, 64, 56, "Hard", "closemenu; skill 2;deathmatch 0; coop 0;newgame\n"); MC_AddConsoleCommand (menu, 64, 72, "Load Game", "menu_load\n"); MC_AddConsoleCommand (menu, 64, 80, "Save Game", "menu_save\n"); diff --git a/engine/client/p_classic.c b/engine/client/p_classic.c index 4c51cdfc5..80f48882f 100644 --- a/engine/client/p_classic.c +++ b/engine/client/p_classic.c @@ -66,7 +66,7 @@ typedef struct cparticle_s pt_grav, pt_slowgrav } type; - unsigned char color; + unsigned int rgb; struct cparticle_s *next; } cparticle_t; @@ -76,10 +76,11 @@ typedef struct cparticle_s static int r_numparticles; static cparticle_t *particles, *active_particles, *free_particles; +extern qbyte default_quakepal[]; /*for ramps more than anything else*/ static int ramp1[8] = {0x6f, 0x6d, 0x6b, 0x69, 0x67, 0x65, 0x63, 0x61}; static int ramp2[8] = {0x6f, 0x6e, 0x6d, 0x6c, 0x6b, 0x6a, 0x68, 0x66}; static int ramp3[8] = {0x6d, 0x6b, 6, 5, 4, 3}; - +#define qpal(q) ((default_quakepal[(q)*3+0]<<0) | (default_quakepal[(q)*3+1]<<8) | (default_quakepal[(q)*3+2]<<16)) #define BUFFERVERTS 2048*3 @@ -350,7 +351,7 @@ static void PClassic_DrawParticles(void) scale = 1 + dist * r_partscale; - usecolours.i = palette[(int)p->color]; + usecolours.i = p->rgb; if (p->type == pt_fire) usecolours.b[3] = 255 * (6 - p->ramp) / 6; else @@ -381,7 +382,7 @@ static void PClassic_DrawParticles(void) if (p->ramp >= 6) p->die = -1; else - p->color = ramp3[(int) p->ramp]; + p->rgb = qpal(ramp3[(int) p->ramp]); p->vel[2] += grav; break; case pt_explode: @@ -389,7 +390,7 @@ static void PClassic_DrawParticles(void) if (p->ramp >=8) p->die = -1; else - p->color = ramp1[(int) p->ramp]; + p->rgb = qpal(ramp1[(int) p->ramp]); for (i = 0; i < 3; i++) p->vel[i] += p->vel[i] * dvel; p->vel[2] -= grav*10; @@ -399,7 +400,7 @@ static void PClassic_DrawParticles(void) if (p->ramp >=8) p->die = -1; else - p->color = ramp2[(int) p->ramp]; + p->rgb = qpal(ramp2[(int) p->ramp]); for (i = 0; i < 3; i++) p->vel[i] -= p->vel[i] * frametime; p->vel[2] -= grav*10; @@ -447,7 +448,7 @@ static void Classic_ParticleExplosion (vec3_t org) active_particles = p; p->die = cl.time + 5; - p->color = ramp1[0]; + p->rgb = d_8to24rgbtable[ramp1[0]]; p->ramp = rand() & 3; if (i & 1) { @@ -489,7 +490,7 @@ static void Classic_BlobExplosion (vec3_t org) if (i & 1) { p->type = pt_blob; - p->color = 66 + rand() % 6; + p->rgb = d_8to24rgbtable[66 + rand() % 6]; for (j = 0; j < 3; j++) { p->org[j] = org[j] + ((rand() % 32) - 16); @@ -499,7 +500,7 @@ static void Classic_BlobExplosion (vec3_t org) else { p->type = pt_blob2; - p->color = 150 + rand() % 6; + p->rgb = d_8to24rgbtable[150 + rand() % 6]; for (j = 0; j < 3; j++) { p->org[j] = org[j] + ((rand() % 32) - 16); @@ -529,7 +530,7 @@ static void Classic_RunParticleEffect (vec3_t org, vec3_t dir, int color, int co active_particles = p; p->die = cl.time + 0.1 * (rand() % 5); - p->color = (color & ~7) + (rand() & 7); + p->rgb = d_8to24rgbtable[(color & ~7) + (rand() & 7)]; p->type = pt_grav; for (j = 0; j < 3; j++) { @@ -560,7 +561,7 @@ static void Classic_LavaSplash (vec3_t org) active_particles = p; p->die = cl.time + 2 + (rand() & 31) * 0.02; - p->color = 224 + (rand() & 7); + p->rgb = d_8to24rgbtable[224 + (rand() & 7)]; p->type = pt_grav; dir[0] = j * 8 + (rand() & 7); @@ -600,7 +601,7 @@ static void Classic_TeleportSplash (vec3_t org) active_particles = p; p->die = cl.time + 0.2 + (rand() & 7) * 0.02; - p->color = 7 + (rand() & 7); + p->rgb = d_8to24rgbtable[7 + (rand() & 7)]; p->type = pt_grav; dir[0] = j * 8; @@ -671,20 +672,20 @@ static float Classic_ParticleTrail (vec3_t start, vec3_t end, float leftover, ef { case GRENADE_TRAIL: p->ramp = (rand() & 3) + 2; - p->color = ramp3[(int) p->ramp]; + p->rgb = d_8to24rgbtable[ramp3[(int) p->ramp]]; p->type = pt_fire; for (j = 0; j < 3; j++) p->org[j] = point[j] + ((rand() % 6) - 3); break; case BLOOD_TRAIL: p->type = pt_slowgrav; - p->color = 67 + (rand() & 3); + p->rgb = d_8to24rgbtable[67 + (rand() & 3)]; for (j = 0; j < 3; j++) p->org[j] = point[j] + ((rand() % 6) - 3); break; case BIG_BLOOD_TRAIL: p->type = pt_slowgrav; - p->color = 67 + (rand() & 3); + p->rgb = d_8to24rgbtable[67 + (rand() & 3)]; for (j = 0; j < 3; j++) p->org[j] = point[j] + ((rand() % 6) - 3); break; @@ -693,9 +694,9 @@ static float Classic_ParticleTrail (vec3_t start, vec3_t end, float leftover, ef p->die = cl.time + 0.5; p->type = pt_static; if (type == TRACER1_TRAIL) - p->color = 52 + ((tracercount & 4) << 1); + p->rgb = d_8to24rgbtable[52 + ((tracercount & 4) << 1)]; else - p->color = 230 + ((tracercount & 4) << 1); + p->rgb = d_8to24rgbtable[230 + ((tracercount & 4) << 1)]; tracercount++; @@ -712,7 +713,7 @@ static float Classic_ParticleTrail (vec3_t start, vec3_t end, float leftover, ef } break; case VOOR_TRAIL: - p->color = 9 * 16 + 8 + (rand() & 3); + p->rgb = d_8to24rgbtable[9 * 16 + 8 + (rand() & 3)]; p->type = pt_static; p->die = cl.time + 0.3; for (j = 0; j < 3; j++) @@ -720,7 +721,7 @@ static float Classic_ParticleTrail (vec3_t start, vec3_t end, float leftover, ef break; case ALT_ROCKET_TRAIL: p->ramp = (rand() & 3); - p->color = ramp3[(int) p->ramp]; + p->rgb = d_8to24rgbtable[ramp3[(int) p->ramp]]; p->type = pt_fire; for (j = 0; j < 3; j++) p->org[j] = point[j] + ((rand() % 6) - 3); @@ -728,7 +729,7 @@ static float Classic_ParticleTrail (vec3_t start, vec3_t end, float leftover, ef case ROCKET_TRAIL: default: p->ramp = (rand() & 3); - p->color = ramp3[(int) p->ramp]; + p->rgb = d_8to24rgbtable[ramp3[(int) p->ramp]]; p->type = pt_fire; for (j = 0; j < 3; j++) p->org[j] = point[j] + ((rand() % 6) - 3); diff --git a/engine/client/p_script.c b/engine/client/p_script.c index 321417076..8cb2a55ef 100644 --- a/engine/client/p_script.c +++ b/engine/client/p_script.c @@ -1897,7 +1897,10 @@ static void P_LoadParticleSet(char *name, qboolean first) fallback->ShutdownParticles(); fallback = &pe_classic; if (fallback) + { fallback->InitParticles(); + fallback->ClearParticles(); + } return; } diff --git a/engine/client/renderer.c b/engine/client/renderer.c index 8befd26db..99d183d9d 100644 --- a/engine/client/renderer.c +++ b/engine/client/renderer.c @@ -839,7 +839,7 @@ void R_SetRenderer(rendererinfo_t *ri) SCR_UpdateScreen = ri->SCR_UpdateScreen; } -static qbyte default_quakepal[768] = +qbyte default_quakepal[768] = { 0,0,0,15,15,15,31,31,31,47,47,47,63,63,63,75,75,75,91,91,91,107,107,107,123,123,123,139,139,139,155,155,155,171,171,171,187,187,187,203,203,203,219,219,219,235,235,235,15,11,7,23,15,11,31,23,11,39,27,15,47,35,19,55,43,23,63,47,23,75,55,27,83,59,27,91,67,31,99,75,31,107,83,31,115,87,31,123,95,35,131,103,35,143,111,35,11,11,15,19,19,27,27,27,39,39,39,51,47,47,63,55,55,75,63,63,87,71,71,103,79,79,115,91,91,127,99,99, 139,107,107,151,115,115,163,123,123,175,131,131,187,139,139,203,0,0,0,7,7,0,11,11,0,19,19,0,27,27,0,35,35,0,43,43,7,47,47,7,55,55,7,63,63,7,71,71,7,75,75,11,83,83,11,91,91,11,99,99,11,107,107,15,7,0,0,15,0,0,23,0,0,31,0,0,39,0,0,47,0,0,55,0,0,63,0,0,71,0,0,79,0,0,87,0,0,95,0,0,103,0,0,111,0,0,119,0,0,127,0,0,19,19,0,27,27,0,35,35,0,47,43,0,55,47,0,67, diff --git a/engine/client/sbar.c b/engine/client/sbar.c index 04ddf6f9c..370febc40 100644 --- a/engine/client/sbar.c +++ b/engine/client/sbar.c @@ -2373,7 +2373,7 @@ void Sbar_Draw (void) Sbar_ExecuteLayoutString(cl.q2statusbar); if (*cl.q2layout) { - if (cl.q2frame.playerstate.stats[Q2STAT_LAYOUTS]) + if (cl.q2frame.playerstate.stats[Q2STAT_LAYOUTS] & 1) Sbar_ExecuteLayoutString(cl.q2layout); } return; diff --git a/engine/client/sys_linux.c b/engine/client/sys_linux.c index 96158dc58..681414e7e 100644 --- a/engine/client/sys_linux.c +++ b/engine/client/sys_linux.c @@ -481,7 +481,8 @@ void *Sys_GetGameAPI(void *parms) char name[MAX_OSPATH]; char curpath[MAX_OSPATH]; char *searchpath; - const char *gamename = "gamei386.so"; + const char *agamename = "gamei386.so"; + const char *ggamename = "game.so"; char *result; void *ret; diff --git a/engine/client/sys_plugfte.c b/engine/client/sys_plugfte.c index e040baae2..dfc7f5de2 100644 --- a/engine/client/sys_plugfte.c +++ b/engine/client/sys_plugfte.c @@ -799,7 +799,7 @@ void pscript_property_curserver_sets(struct context *ctx, const char *val) } Q_strncpyz(cls.servername, val, sizeof(cls.servername)); - CL_BeginServerConnect(); + CL_BeginServerConnect(0); } void pscript_property_stream_sets(struct context *ctx, const char *val) diff --git a/engine/client/view.c b/engine/client/view.c index 34924597d..9ccecd87f 100644 --- a/engine/client/view.c +++ b/engine/client/view.c @@ -1335,7 +1335,6 @@ void V_RenderPlayerViews(int plnum) { extern vec3_t desired_position[MAX_SPLITS]; vec3_t dir; - extern void vectoangles(vec3_t vec, vec3_t ang); r_refdef.vrect.y -= r_refdef.vrect.height; vid.recalc_refdef=true; diff --git a/engine/common/bothdefs.h b/engine/common/bothdefs.h index 91b30f682..590c14641 100644 --- a/engine/common/bothdefs.h +++ b/engine/common/bothdefs.h @@ -92,6 +92,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. //#define DYNAMIC_LIBPNG //#define DYNAMIC_LIBJPEG +#if defined(_MSC_VER) //too lazy to fix up the makefile +//#define BOTLIB_STATIC +#endif + #define AVAIL_FREETYPE #ifdef _WIN32 //needs testing on other platforms diff --git a/engine/common/bspfile.h b/engine/common/bspfile.h index f52f7d42c..f06137964 100644 --- a/engine/common/bspfile.h +++ b/engine/common/bspfile.h @@ -177,6 +177,11 @@ typedef struct short children[2]; // negative numbers are contents } dclipnode_t; +typedef struct +{ + int planenum; + short children[2]; // negative numbers are contents +} mclipnode_t; typedef struct texinfo_s { diff --git a/engine/common/common.c b/engine/common/common.c index c1b8afe4a..360f61ebc 100644 --- a/engine/common/common.c +++ b/engine/common/common.c @@ -188,7 +188,7 @@ void InsertLinkAfter (link_t *l, link_t *after) ============================================================================ */ -void Q_strncpyz(char *d, const char *s, int n) +void QDECL Q_strncpyz(char *d, const char *s, int n) { int i; n--; @@ -339,7 +339,9 @@ int Q_strncmp (char *s1, char *s2, int count) return -1; } -int Q_strncasecmp (char *s1, char *s2, int n) +#endif + +int Q_strncasecmp (const char *s1, const char *s2, int n) { int c1, c2; @@ -369,12 +371,35 @@ int Q_strncasecmp (char *s1, char *s2, int n) return -1; } -int Q_strcasecmp (char *s1, char *s2) +int Q_strcasecmp (const char *s1, const char *s2) +{ + return Q_strncasecmp (s1, s2, 99999); +} +int QDECL Q_stricmp (const char *s1, const char *s2) { return Q_strncasecmp (s1, s2, 99999); } -#endif +int QDECL Q_vsnprintf(char *buffer, int size, const char *format, va_list argptr) +{ + return vsnprintf(buffer, size, format, argptr); +} + +int VARGS Com_sprintf(char *buffer, int size, const char *format, ...) LIKEPRINTF(3) +{ + int ret; + va_list argptr; + + va_start (argptr, format); + ret = vsnprintf (buffer, size, format, argptr); + va_end (argptr); + + return ret; +} +void QDECL Com_Error( int level, const char *error, ... ) +{ + Sys_Error("%s", error); +} char *Q_strlwr(char *s) { @@ -1488,6 +1513,7 @@ void MSGQ2_ReadDeltaUsercmd (usercmd_t *from, usercmd_t *move) // read buttons if (bits & Q2CM_BUTTONS) move->buttons = MSG_ReadByte (); + move->buttons_compat = move->buttons & 0xff; if (bits & Q2CM_IMPULSE) move->impulse = MSG_ReadByte (); diff --git a/engine/common/common.h b/engine/common/common.h index 510c1310e..539da24cb 100644 --- a/engine/common/common.h +++ b/engine/common/common.h @@ -19,6 +19,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // comndef.h -- general definitions +#include + +//make shared +#ifndef QDECL + #ifdef _MSC_VER + #define QDECL _cdecl + #else + #define QDECL + #endif +#endif + typedef unsigned char qbyte; // KJB Undefined true and false defined in SciTech's DEBUG.H header @@ -208,7 +219,7 @@ void VARGS Q_snprintfz (char *dest, size_t size, char *fmt, ...) LIKEPRINTF(3); #if 0 #define Q_strncpyz(d, s, n) Q_strncpyN(d, s, (n)-1) #else -void Q_strncpyz(char*d, const char*s, int n); +void QDECL Q_strncpyz(char*d, const char*s, int n); #define Q_strncatz(dest, src, sizeofdest) \ do { \ strncat(dest, src, sizeofdest - strlen(dest) - 1); \ @@ -221,18 +232,10 @@ void Q_strncpyz(char*d, const char*s, int n); #define strncpy Q_strncpy #endif*/ -#ifdef _WIN32 - -#define Q_strcasecmp(s1, s2) _stricmp((s1), (s2)) -#define Q_strncasecmp(s1, s2, n) _strnicmp((s1), (s2), (n)) - -#else - -#define Q_strcasecmp(s1, s2) strcasecmp((s1), (s2)) -#define Q_strncasecmp(s1, s2, n) strncasecmp((s1), (s2), (n)) - -#endif +/*replacement functions which do not care for locale in text formatting ('C' locale)*/ +int Q_strncasecmp (const char *s1, const char *s2, int n); +int Q_strcasecmp (const char *s1, const char *s2); int Q_atoi (const char *str); float Q_atof (const char *str); @@ -458,3 +461,17 @@ void Log_String (logtype_t lognum, char *s); void Con_Log (char *s); void Log_Logfile_f (void); void Log_Init(void); + + +/*used by and for botlib and q3 gamecode*/ +#define MAX_TOKENLENGTH 1024 +typedef struct pc_token_s +{ + int type; + int subtype; + int intvalue; + float floatvalue; + char string[MAX_TOKENLENGTH]; +} pc_token_t; +#define fileHandle_t int +#define fsMode_t int diff --git a/engine/common/crc.c b/engine/common/crc.c index 6a4ce08e6..bebc30812 100644 --- a/engine/common/crc.c +++ b/engine/common/crc.c @@ -73,7 +73,7 @@ void QCRC_Init(unsigned short *crcvalue) void QCRC_ProcessByte(unsigned short *crcvalue, qbyte data) { - *crcvalue = (*crcvalue << 8) ^ crctable[(*crcvalue >> 8) ^ data]; + *crcvalue = ((*crcvalue << 8)&0xffff) ^ crctable[(*crcvalue >> 8) ^ data]; } unsigned short QCRC_Value(unsigned short crcvalue) @@ -87,7 +87,7 @@ unsigned short QCRC_Block (qbyte *start, int count) QCRC_Init (&crc); while (count--) - crc = (crc << 8) ^ crctable[(crc >> 8) ^ *start++]; + crc = ((crc << 8) & 0xffff) ^ crctable[(crc >> 8) ^ *start++]; return crc; } diff --git a/engine/common/fs.c b/engine/common/fs.c index cb45ee04f..3e6c4d79b 100644 --- a/engine/common/fs.c +++ b/engine/common/fs.c @@ -1632,10 +1632,16 @@ void COM_Gamedir (const char *dir) #endif } +/*stuff that makes dp-only mods work a bit better*/ #define DPCOMPAT "set _cl_playermodel \"\"\n set dpcompat_set 1\n set dpcompat_trailparticles 1\nset dpcompat_corruptglobals 1\nset vid_pixelheight 1\n" -#define NEXCFG DPCOMPAT "set r_particlesdesc effectinfo\nset sv_maxairspeed \"400\"\nset sv_jumpvelocity 270\nset sv_mintic \"0.01\"\ncl_nolerp 0\nset r_particlesdesc effectinfo\n" +/*nexuiz/xonotic has a few quirks...*/ +#define NEXCFG DPCOMPAT "set r_particlesdesc effectinfo\nset sv_maxairspeed \"400\"\nset sv_jumpvelocity 270\nset sv_mintic \"0.01\"\ncl_nolerp 0\n" +/*some modern non-compat settings*/ #define DMFCFG "set com_parseutf8 1\npm_airstep 1\n" +/*set some stuff so our regular qw client appears more like hexen2*/ #define HEX2CFG "set r_particlesdesc \"spikeset tsshaft h2part\"\nset sv_maxspeed 640\nset watervis 1\nset r_wateralpha 0.5\nset sv_pupglow 1\nset cl_model_bobbing 1\n" +/*Q3's ui doesn't like empty model/headmodel/handicap cvars, even if the gamecode copes*/ +#define Q3CFG "seta model sarge\nseta headmodel sarge\nseta handicap 100\n" typedef struct { const char *protocolname; //sent to the master server when this is the current gamemode. @@ -1666,7 +1672,7 @@ const gamemode_info_t gamemode_info[] = { "portals/pak3.pak"}, HEX2CFG,{"data1", "portals", "fteh2"}, "Hexen II MP"}, {"FTE-Hexen2", "hexen2", "-hexen2", {"data1/pak0.pak"}, HEX2CFG,{"data1", "fteh2"}, "Hexen II"}, {"FTE-Quake2", "q2", "-q2", {"baseq2/pak0.pak"}, NULL, {"baseq2", "fteq2"}, "Quake II"}, - {"FTE-Quake3", "q3", "-q3", {"baseq3/pak0.pk3"}, NULL, {"baseq3", "fteq3"}, "Quake III Arena"}, + {"FTE-Quake3", "q3", "-q3", {"baseq3/pak0.pk3"}, Q3CFG, {"baseq3", "fteq3"}, "Quake III Arena"}, {"FTE-Quake4", "q4", "-q4", {"q4base/pak00.pk4"}, NULL, {"q4base", "fteq4"}, "Quake 4"}, {"FTE-EnemyTerritory", "et", "-et", {"etmain/pak0.pk3"}, NULL, {"etmain", "fteet"}, "Wolfenstein - Enemy Territory"}, diff --git a/engine/common/gl_q2bsp.c b/engine/common/gl_q2bsp.c index 6733e294e..3fdc54f1e 100644 --- a/engine/common/gl_q2bsp.c +++ b/engine/common/gl_q2bsp.c @@ -2357,14 +2357,9 @@ mfog_t *CM_FogForOrigin(vec3_t org) //Convert a patch in to a list of glpolys -#define MAX_ARRAY_VERTS 2048 +#define MAX_ARRAY_VERTS 65535 -index_t tempIndexesArray[MAX_ARRAY_VERTS*3]; -vecV_t tempxyz_array[MAX_ARRAY_VERTS]; //structure is used only at load. -vec3_t tempnormals_array[MAX_ARRAY_VERTS]; //so what harm is there in doing this? -vec2_t tempst_array[MAX_ARRAY_VERTS]; -vec2_t templmst_array[MAX_ARRAY_VERTS]; -byte_vec4_t tempcolors_array[MAX_ARRAY_VERTS]; +index_t tempIndexesArray[MAX_ARRAY_VERTS*6]; //mesh_t *GL_CreateMeshForPatch ( model_t *mod, q3dface_t *surf ) mesh_t *GL_CreateMeshForPatch (model_t *mod, int patchwidth, int patchheight, int numverts, int firstvert) @@ -2633,6 +2628,8 @@ qboolean CModQ3_LoadRFaces (lump_t *l) Vector4Copy(mesh->colors4b_array[0], mesh->colors4b_array[2]); Vector4Copy(mesh->colors4b_array[0], mesh->colors4b_array[3]); } + if (out->mesh->numindexes == 0) + Con_Printf("foo\n"); } Mod_NormaliseTextureVectors(map_normals_array, map_svector_array, map_tvector_array, numvertexes); diff --git a/engine/common/mathlib.c b/engine/common/mathlib.c index 36cf7f21a..83ef6a7f1 100644 --- a/engine/common/mathlib.c +++ b/engine/common/mathlib.c @@ -368,7 +368,7 @@ void VectorAngles(float *forward, float *up, float *result) //up may be NULL result[2] = roll; } -void AngleVectors (const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up) +void QDECL AngleVectors (const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up) { float angle; float sr, sp, sy, cr, cp, cy; @@ -403,6 +403,36 @@ void AngleVectors (const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up) } } +void QDECL vectoangles(vec3_t vec, vec3_t ang) +{ + float forward; + float yaw, pitch; + + if (vec[1] == 0 && vec[0] == 0) + { + yaw = 0; + if (vec[2] > 0) + pitch = 90; + else + pitch = 270; + } + else + { + yaw = /*(int)*/ (atan2(vec[1], vec[0]) * 180 / M_PI); + if (yaw < 0) + yaw += 360; + + forward = sqrt (vec[0]*vec[0] + vec[1]*vec[1]); + pitch = /*(int)*/ (atan2(vec[2], forward) * 180 / M_PI); + if (pitch < 0) + pitch += 360; + } + + ang[0] = pitch; + ang[1] = yaw; + ang[2] = 0; +} + int VectorCompare (const vec3_t v1, const vec3_t v2) { int i; @@ -485,7 +515,7 @@ float Q_rsqrt(float number) return y; } -float VectorNormalize (vec3_t v) +float QDECL VectorNormalize (vec3_t v) { float length, ilength; @@ -1637,7 +1667,7 @@ void Matrix3_Multiply (vec3_t *in1, vec3_t *in2, vec3_t *out) out[2][2] = in1[2][0]*in2[0][2] + in1[2][1]*in2[1][2] + in1[2][2]*in2[2][2]; } -vec_t VectorNormalize2 (const vec3_t v, vec3_t out) +vec_t QDECL VectorNormalize2 (const vec3_t v, vec3_t out) { float length, ilength; diff --git a/engine/common/mathlib.h b/engine/common/mathlib.h index 4d3c60d83..38d4b4abb 100644 --- a/engine/common/mathlib.h +++ b/engine/common/mathlib.h @@ -115,7 +115,7 @@ void _VectorCopy (vec3_t in, vec3_t out); void _VectorSubtract (vec3_t veca, vec3_t vecb, vec3_t out); void AddPointToBounds (vec3_t v, vec3_t mins, vec3_t maxs); float anglemod (float a); -void AngleVectors (const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up); +void QDECL AngleVectors (const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up); void VectorAngles (float *forward, float *up, float *angles); //up may be NULL void VARGS BOPS_Error (void); int VARGS BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct mplane_s *plane); @@ -173,8 +173,8 @@ void RotateLightVector(const vec3_t *axis, const vec3_t origin, const vec3_t li int VectorCompare (const vec3_t v1, const vec3_t v2); void VectorInverse (vec3_t v); void _VectorMA (const vec3_t veca, const float scale, const vec3_t vecb, vec3_t vecc); -float VectorNormalize (vec3_t v); // returns vector length -vec_t VectorNormalize2 (const vec3_t v, vec3_t out); +float QDECL VectorNormalize (vec3_t v); // returns vector length +vec_t QDECL VectorNormalize2 (const vec3_t v, vec3_t out); void VectorNormalizeFast(vec3_t v); void VectorTransform (const vec3_t in1, const matrix3x4 in2, vec3_t out); void VectorVectors (const vec3_t forward, vec3_t right, vec3_t up); diff --git a/engine/common/pmovetst.c b/engine/common/pmovetst.c index 1ec43a5cb..54ceef5c6 100644 --- a/engine/common/pmovetst.c +++ b/engine/common/pmovetst.c @@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static qboolean PM_TransformedHullCheck (model_t *model, vec3_t start, vec3_t end, trace_t *trace, vec3_t origin, vec3_t angles); int Q1BSP_HullPointContents(hull_t *hull, vec3_t p); static hull_t box_hull; -static dclipnode_t box_clipnodes[6]; +static mclipnode_t box_clipnodes[6]; static mplane_t box_planes[6]; extern vec3_t player_mins; diff --git a/engine/common/protocol.h b/engine/common/protocol.h index 8f90e289f..06858ac4f 100644 --- a/engine/common/protocol.h +++ b/engine/common/protocol.h @@ -798,14 +798,15 @@ typedef struct usercmd_s { //the first members of this structure MUST match the q2 version qbyte msec; - qbyte buttons; + qbyte buttons_compat; short angles[3]; short forwardmove, sidemove, upmove; qbyte impulse; qbyte lightlevel; //freestyle - qbyte weapon; + int buttons; + int weapon; int servertime; float fservertime; float fclienttime; diff --git a/engine/common/q1bsp.c b/engine/common/q1bsp.c index 6b8e3be7f..1e509914d 100644 --- a/engine/common/q1bsp.c +++ b/engine/common/q1bsp.c @@ -11,7 +11,7 @@ Physics functions (common) void Q1BSP_CheckHullNodes(hull_t *hull) { int num, c; - dclipnode_t *node; + mclipnode_t *node; for (num = hull->firstclipnode; num < hull->lastclipnode; num++) { node = hull->clipnodes + num; @@ -32,7 +32,7 @@ SV_HullPointContents static int Q1_HullPointContents (hull_t *hull, int num, vec3_t p) { float d; - dclipnode_t *node; + mclipnode_t *node; mplane_t *plane; while (num >= 0) @@ -205,7 +205,7 @@ qboolean Q1BSP_RecursiveHullCheck (hull_t *hull, int num, float p1f, float p2f, #else qboolean Q1BSP_RecursiveHullCheck (hull_t *hull, int num, float p1f, float p2f, vec3_t p1, vec3_t p2, trace_t *trace) { - dclipnode_t *node; + mclipnode_t *node; mplane_t *plane; float t1, t2; float frac; @@ -1007,7 +1007,9 @@ int Q1BSP_ClipDecal(vec3_t center, vec3_t normal, vec3_t tangent1, vec3_t tangen sh_shadowframe++; - if (cl.worldmodel->fromgame == fg_quake) + if (!cl.worldmodel) + return 0; + else if (cl.worldmodel->fromgame == fg_quake) Q1BSP_ClipDecalToNodes(&dec, cl.worldmodel->nodes); #ifdef Q3BSPS else if (cl.worldmodel->fromgame == fg_quake3) diff --git a/engine/common/q3common.c b/engine/common/q3common.c index 8bbe6bdee..1a1180e53 100644 --- a/engine/common/q3common.c +++ b/engine/common/q3common.c @@ -1642,7 +1642,8 @@ void MSG_Q3_ReadDeltaPlayerstate( const q3playerState_t *from, q3playerState_t * //////////////////////////////////////////////////////////// //user commands -int kbitmask[32] = { +int kbitmask[] = { + 0, 0x00000001, 0x00000003, 0x00000007, 0x0000000F, 0x0000001F, 0x0000003F, 0x0000007F, 0x000000FF, 0x000001FF, 0x000003FF, 0x000007FF, 0x00000FFF, @@ -1656,7 +1657,7 @@ int kbitmask[32] = { static int MSG_ReadDeltaKey(int key, int from, int bits) { if (MSG_ReadBits(1)) - return MSG_ReadBits(bits)^ (key & kbitmask[bits]); + return MSG_ReadBits(bits) ^ (key & kbitmask[bits]); else return from; } @@ -1666,7 +1667,14 @@ void MSG_Q3_ReadDeltaUsercmd(int key, const usercmd_t *from, usercmd_t *to) to->servertime = MSG_ReadBits(8) + from->servertime; else to->servertime = MSG_ReadBits(32); - to->msec = to->servertime - from->servertime; + + if ((unsigned int)(to->servertime - from->servertime) > 255) + { + Con_DPrintf("msecs clamped\n"); + to->msec = 255; + } + else + to->msec = to->servertime - from->servertime; if (!MSG_ReadBits(1)) { diff --git a/engine/common/world.h b/engine/common/world.h index bec23d182..ce024b2aa 100644 --- a/engine/common/world.h +++ b/engine/common/world.h @@ -99,8 +99,7 @@ typedef struct areanode_s int axis; // -1 = leaf node float dist; struct areanode_s *children[2]; - link_t trigger_edicts; - link_t solid_edicts; + link_t edicts; } areanode_t; #define AREA_DEPTH 4 diff --git a/engine/common/zone.c b/engine/common/zone.c index 3df0f1d57..023be6842 100644 --- a/engine/common/zone.c +++ b/engine/common/zone.c @@ -2142,7 +2142,7 @@ void Memory_Init (void *buf, int size) #if ZONEDEBUG>0 || HUNKDEBUG>0 || TEMPDEBUG>0||CACHEDEBUG>0 srand(time(0)); - sentinalkey = rand(); + sentinalkey = rand() & 0xff; #endif Cache_Init (); diff --git a/engine/dotnet2005/botlib.vcproj b/engine/dotnet2005/botlib.vcproj new file mode 100644 index 000000000..de5c4ff51 --- /dev/null +++ b/engine/dotnet2005/botlib.vcproj @@ -0,0 +1,407 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/engine/dotnet2005/ftequake.sln b/engine/dotnet2005/ftequake.sln index e39ee4969..30179959c 100644 --- a/engine/dotnet2005/ftequake.sln +++ b/engine/dotnet2005/ftequake.sln @@ -1,10 +1,16 @@ Microsoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftequake", "ftequake.vcproj", "{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}" + ProjectSection(ProjectDependencies) = postProject + {0018E098-B12A-4E4D-9B22-6772DA287080} = {0018E098-B12A-4E4D-9B22-6772DA287080} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftequake_SDL", "ftequake_SDL.vcproj", "{F384725A-62D4-4063-9941-6D8D2D6C2A47}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "npfte", "npfte.vcproj", "{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}" + ProjectSection(ProjectDependencies) = postProject + {0018E098-B12A-4E4D-9B22-6772DA287080} = {0018E098-B12A-4E4D-9B22-6772DA287080} + EndProjectSection EndProject Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "FTEQuake", "..\setup\setup.vdproj", "{E0EE8B50-3A75-42A9-B80A-787675979B0C}" EndProject @@ -13,6 +19,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "qtvprox", "..\..\fteqtv\qtv {88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365} = {88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "botlib", "botlib.vcproj", "{0018E098-B12A-4E4D-9B22-6772DA287080}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution D3DDebug|Win32 = D3DDebug|Win32 @@ -130,7 +138,6 @@ Global {88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.GLDebug|x64.ActiveCfg = GLDebug|x64 {88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.GLDebug|x64.Build.0 = GLDebug|x64 {88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.GLRelease|Win32.ActiveCfg = GLRelease|Win32 - {88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.GLRelease|Win32.Build.0 = GLRelease|Win32 {88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.GLRelease|x64.ActiveCfg = GLRelease|x64 {88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.GLRelease|x64.Build.0 = GLRelease|x64 {88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.MDebug|Win32.ActiveCfg = GLRelease|x64 @@ -215,6 +222,40 @@ Global {1A353DA0-F351-4C0D-A21D-E2B460600B20}.Release|Win32.ActiveCfg = Release|Win32 {1A353DA0-F351-4C0D-A21D-E2B460600B20}.Release|Win32.Build.0 = Release|Win32 {1A353DA0-F351-4C0D-A21D-E2B460600B20}.Release|x64.ActiveCfg = Release|Win32 + {0018E098-B12A-4E4D-9B22-6772DA287080}.D3DDebug|Win32.ActiveCfg = Debug|Win32 + {0018E098-B12A-4E4D-9B22-6772DA287080}.D3DDebug|Win32.Build.0 = Debug|Win32 + {0018E098-B12A-4E4D-9B22-6772DA287080}.D3DDebug|x64.ActiveCfg = Debug|Win32 + {0018E098-B12A-4E4D-9B22-6772DA287080}.D3DRelease|Win32.ActiveCfg = Release|Win32 + {0018E098-B12A-4E4D-9B22-6772DA287080}.D3DRelease|Win32.Build.0 = Release|Win32 + {0018E098-B12A-4E4D-9B22-6772DA287080}.D3DRelease|x64.ActiveCfg = Release|Win32 + {0018E098-B12A-4E4D-9B22-6772DA287080}.Debug Dedicated Server|Win32.ActiveCfg = Debug|Win32 + {0018E098-B12A-4E4D-9B22-6772DA287080}.Debug Dedicated Server|Win32.Build.0 = Debug|Win32 + {0018E098-B12A-4E4D-9B22-6772DA287080}.Debug Dedicated Server|x64.ActiveCfg = Debug|Win32 + {0018E098-B12A-4E4D-9B22-6772DA287080}.Debug|Win32.ActiveCfg = Debug|Win32 + {0018E098-B12A-4E4D-9B22-6772DA287080}.Debug|Win32.Build.0 = Debug|Win32 + {0018E098-B12A-4E4D-9B22-6772DA287080}.Debug|x64.ActiveCfg = Debug|Win32 + {0018E098-B12A-4E4D-9B22-6772DA287080}.GLDebug|Win32.ActiveCfg = Debug|Win32 + {0018E098-B12A-4E4D-9B22-6772DA287080}.GLDebug|Win32.Build.0 = Debug|Win32 + {0018E098-B12A-4E4D-9B22-6772DA287080}.GLDebug|x64.ActiveCfg = Debug|Win32 + {0018E098-B12A-4E4D-9B22-6772DA287080}.GLRelease|Win32.ActiveCfg = Release|Win32 + {0018E098-B12A-4E4D-9B22-6772DA287080}.GLRelease|Win32.Build.0 = Release|Win32 + {0018E098-B12A-4E4D-9B22-6772DA287080}.GLRelease|x64.ActiveCfg = Release|Win32 + {0018E098-B12A-4E4D-9B22-6772DA287080}.MDebug|Win32.ActiveCfg = Debug|Win32 + {0018E098-B12A-4E4D-9B22-6772DA287080}.MDebug|Win32.Build.0 = Debug|Win32 + {0018E098-B12A-4E4D-9B22-6772DA287080}.MDebug|x64.ActiveCfg = Debug|Win32 + {0018E098-B12A-4E4D-9B22-6772DA287080}.MinGLDebug|Win32.ActiveCfg = Debug|Win32 + {0018E098-B12A-4E4D-9B22-6772DA287080}.MinGLDebug|x64.ActiveCfg = Debug|Win32 + {0018E098-B12A-4E4D-9B22-6772DA287080}.MinGLRelease|Win32.ActiveCfg = Release|Win32 + {0018E098-B12A-4E4D-9B22-6772DA287080}.MinGLRelease|x64.ActiveCfg = Release|Win32 + {0018E098-B12A-4E4D-9B22-6772DA287080}.MRelease|Win32.ActiveCfg = Release|Win32 + {0018E098-B12A-4E4D-9B22-6772DA287080}.MRelease|Win32.Build.0 = Release|Win32 + {0018E098-B12A-4E4D-9B22-6772DA287080}.MRelease|x64.ActiveCfg = Release|Win32 + {0018E098-B12A-4E4D-9B22-6772DA287080}.Release Dedicated Server|Win32.ActiveCfg = Release|Win32 + {0018E098-B12A-4E4D-9B22-6772DA287080}.Release Dedicated Server|Win32.Build.0 = Release|Win32 + {0018E098-B12A-4E4D-9B22-6772DA287080}.Release Dedicated Server|x64.ActiveCfg = Release|Win32 + {0018E098-B12A-4E4D-9B22-6772DA287080}.Release|Win32.ActiveCfg = Release|Win32 + {0018E098-B12A-4E4D-9B22-6772DA287080}.Release|Win32.Build.0 = Release|Win32 + {0018E098-B12A-4E4D-9B22-6772DA287080}.Release|x64.ActiveCfg = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/engine/dotnet2005/ftequake.vcproj b/engine/dotnet2005/ftequake.vcproj index 314f55372..2233c9e61 100644 --- a/engine/dotnet2005/ftequake.vcproj +++ b/engine/dotnet2005/ftequake.vcproj @@ -839,6 +839,7 @@ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="false" + WholeProgramOptimization="1" > @@ -911,6 +908,7 @@ /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/engine/gl/gl_font.c b/engine/gl/gl_font.c index f01df61b5..7ff753e73 100644 --- a/engine/gl/gl_font.c +++ b/engine/gl/gl_font.c @@ -929,7 +929,7 @@ struct font_s *Font_LoadFont(int height, char *fontfilename) f->chars[i].bmh = PLANEWIDTH/16; f->chars[i].bmw = PLANEWIDTH/16; f->chars[i].bmx = (i&15)*(PLANEWIDTH/16); - f->chars[i].bmy = (i/16)*(PLANEWIDTH/16); + f->chars[i].bmy = ((i/16)*(PLANEWIDTH/16)) & 0xff; f->chars[i].left = 0; f->chars[i].top = 0; f->chars[i].nextchar = 0; //these chars are not linked in diff --git a/engine/gl/gl_model.c b/engine/gl/gl_model.c index 6a666d189..7bc27e366 100644 --- a/engine/gl/gl_model.c +++ b/engine/gl/gl_model.c @@ -2306,7 +2306,8 @@ Mod_LoadClipnodes */ qboolean RMod_LoadClipnodes (lump_t *l) { - dclipnode_t *in, *out; + dclipnode_t *in; + mclipnode_t *out; int i, count; hull_t *hull; @@ -2527,7 +2528,7 @@ Deplicate the drawing hull structure as a clipping hull void RMod_MakeHull0 (void) { mnode_t *in, *child; - dclipnode_t *out; + mclipnode_t *out; int i, j, count; hull_t *hull; diff --git a/engine/gl/gl_model.h b/engine/gl/gl_model.h index a8933f251..b016ffccc 100644 --- a/engine/gl/gl_model.h +++ b/engine/gl/gl_model.h @@ -446,7 +446,7 @@ typedef struct // !!! if this is changed, it must be changed in asm_i386.h too !!! typedef struct hull_s { - dclipnode_t *clipnodes; + mclipnode_t *clipnodes; mplane_t *planes; int firstclipnode; int lastclipnode; @@ -859,7 +859,7 @@ typedef struct model_s int *surfedges; int numclipnodes; - dclipnode_t *clipnodes; + mclipnode_t *clipnodes; int nummarksurfaces; msurface_t **marksurfaces; diff --git a/engine/gl/gl_rlight.c b/engine/gl/gl_rlight.c index 6c0ea3080..faabf04fb 100644 --- a/engine/gl/gl_rlight.c +++ b/engine/gl/gl_rlight.c @@ -238,7 +238,7 @@ void GLR_RenderDlights (void) l = cl_dlights+rtlights_first; for (i=rtlights_first; iradius)// || !(l->flags & LFLAG_ALLOW_FLASH)) + if (!l->radius || !(l->flags & LFLAG_ALLOW_FLASH)) continue; //dlights emitting from the local player are not visible as flashblends diff --git a/engine/gl/gl_shader.c b/engine/gl/gl_shader.c index efae7e4ca..3fd215201 100644 --- a/engine/gl/gl_shader.c +++ b/engine/gl/gl_shader.c @@ -1122,7 +1122,7 @@ struct sbuiltin_s "}\n" "#endif\n" }, - {QR_OPENGL, 110, "defaultsky", +/* {QR_OPENGL, 110, "defaultsky", "#ifdef VERTEX_SHADER\n" "varying vec3 pos;\n" @@ -1156,10 +1156,10 @@ struct sbuiltin_s " vec4 clouds = texture2D(s_t1, tccoord);\n" " gl_FragColor.rgb = (solid.rgb*(1.0-clouds.a)) + (clouds.a*clouds.rgb);\n" -// " gl_FragColor.rgb = solid.rgb;/*gl_FragColor.g = clouds.r;*/gl_FragColor.b = clouds.a;\n" "}\n" "#endif\n" }, +*/ /*draws a model. there's lots of extra stuff for light shading calcs and upper/lower textures*/ {QR_OPENGL/*ES*/, 100, "defaultskin", "!!permu FULLBRIGHT\n" diff --git a/engine/gl/gl_warp.c b/engine/gl/gl_warp.c index 509937ea6..49b38cdb8 100644 --- a/engine/gl/gl_warp.c +++ b/engine/gl/gl_warp.c @@ -459,7 +459,6 @@ static void R_DrawSkyMesh(batch_t *batch, mesh_t *m, shader_t *shader) { static entity_t skyent; batch_t b; - //float time = cl.gametime+realtime-cl.gametimemark; //warning: unused variable ‘time’ float skydist = gl_skyboxdist.value; if (skydist<1) diff --git a/engine/server/pr_cmds.c b/engine/server/pr_cmds.c index 272e0a2a8..5d7a42f45 100644 --- a/engine/server/pr_cmds.c +++ b/engine/server/pr_cmds.c @@ -2497,7 +2497,7 @@ static void QCBUILTIN PF_particle (progfuncs_t *prinst, globalvars_t *pr_globals v = -128; MSG_WriteChar (&sv.nqmulticast, v); } - MSG_WriteByte (&sv.nqmulticast, count*20); + MSG_WriteByte (&sv.nqmulticast, count); MSG_WriteByte (&sv.nqmulticast, color); #endif //for qw users (and not fte) @@ -2743,6 +2743,9 @@ void PF_ambientsound_Internal (float *pos, char *samp, float vol, float attenuat SV_FlushSignon(); + if (soundnum > 255) + return; + // add an svc_spawnambient command to the level signon packet MSG_WriteByte (&sv.signon,svc_spawnstaticsound); diff --git a/engine/server/pr_q1qvm.c b/engine/server/pr_q1qvm.c index 0da3ae941..339a95f1b 100755 --- a/engine/server/pr_q1qvm.c +++ b/engine/server/pr_q1qvm.c @@ -293,8 +293,6 @@ typedef struct int APIversion; } gameData32_t; -typedef int fileHandle_t; - typedef enum { FS_READ_BIN, FS_READ_TXT, @@ -302,7 +300,7 @@ typedef enum { FS_WRITE_TXT, FS_APPEND_BIN, FS_APPEND_TXT -} fsMode_t; +} q1qvmfsMode_t; typedef enum { FS_SEEK_CUR, @@ -940,8 +938,28 @@ static qintptr_t syscallhandle (void *offset, quintptr_t mask, qintptr_t fn, con //ret = filesize or -1 // Con_Printf("G_FSOpenFile: %s (mode %i)\n", VM_POINTER(arg[0]), arg[2]); - - return VM_fopen(VM_POINTER(arg[0]), VM_POINTER(arg[1]), arg[2]/2, VMFSID_Q1QVM); + { + int mode; + switch((q1qvmfsMode_t)arg[2]) + { + default: + return -1; + case FS_READ_BIN: + case FS_READ_TXT: + mode = VM_FS_READ; + break; + case FS_WRITE_BIN: + case FS_WRITE_TXT: + mode = VM_FS_WRITE; + break; + case FS_APPEND_BIN: + case FS_APPEND_TXT: + mode = VM_FS_APPEND; + break; + } + return VM_fopen(VM_POINTER(arg[0]), VM_POINTER(arg[1]), mode, VMFSID_Q1QVM); + } + break; case G_FS_CloseFile: VM_fclose(arg[0], VMFSID_Q1QVM); diff --git a/engine/server/savegame.c b/engine/server/savegame.c index 3ffe4ea60..1265b9134 100644 --- a/engine/server/savegame.c +++ b/engine/server/savegame.c @@ -563,7 +563,7 @@ qboolean SV_LoadLevelCache(char *savename, char *level, char *startspot, qboolea return false; } - if (!FS_NativePath(name, FS_GAMEONLY, syspath, sizeof(syspath))) + if (!FS_NativePath(name, FS_GAME, syspath, sizeof(syspath))) return false; ge->ReadLevel(syspath); @@ -895,7 +895,7 @@ void SV_SaveLevelCache(char *savedir, qboolean dontharmgame) #define FTESAVEGAME_VERSION 25000 -void SV_Savegame_f (void) +void SV_Savegame (char *savename) { extern cvar_t nomonsters; extern cvar_t gamecfg; @@ -919,7 +919,6 @@ void SV_Savegame_f (void) char comment[SAVEGAME_COMMENT_LENGTH+1]; vfsfile_t *f; int len; - char *savename; levelcache_t *cache; char str[MAX_LOCALINFO_STRING+1]; char *savefilename; @@ -930,8 +929,7 @@ void SV_Savegame_f (void) return; } - savename = Cmd_Argv(1); - + /*catch invalid names*/ if (!*savename || strstr(savename, "..")) savename = "quicksav"; @@ -1017,6 +1015,11 @@ void SV_Savegame_f (void) FS_FlushFSHash(); } +void SV_Savegame_f (void) +{ + SV_Savegame(Cmd_Argv(1)); +} + void SV_Loadgame_f (void) { levelcache_t *cache; diff --git a/engine/server/server.h b/engine/server/server.h index 39a8ae4ef..a3798f220 100644 --- a/engine/server/server.h +++ b/engine/server/server.h @@ -936,6 +936,7 @@ void SV_WriteDelta (entity_state_t *from, entity_state_t *to, sizebuf_t *msg, qb void SV_SaveSpawnparms (qboolean); void SV_SaveLevelCache(char *savename, qboolean dontharmgame); +void SV_Savegame (char *savename); qboolean SV_LoadLevelCache(char *savename, char *level, char *startspot, qboolean ignoreplayers); void SV_Physics_Client (edict_t *ent, int num); diff --git a/engine/server/sv_ccmds.c b/engine/server/sv_ccmds.c index 1b2349da6..ff82f04c4 100644 --- a/engine/server/sv_ccmds.c +++ b/engine/server/sv_ccmds.c @@ -424,6 +424,16 @@ SV_Map_f handle a map command from the console or progs. + +quirks: +a leading '*' means new unit, meaning all old state is flushed regardless of startspot +a '+' means 'set nextmap cvar to the following value and otherwise ignore, for q2 compat. only applies if there's also a '.' and the specified bsp doesn't exist, for q1 compat. +just a '.' is taken to mean 'restart'. parms are not changed from their current values, startspot is also unchanged. + +'map' will change map, for most games. note that NQ kicks everyone (NQ expects you to use changelevel for that). +'changelevel' will not flush the level cache, for h2 compat (won't save current level state in such a situation, as nq would prefer not) +'gamemap' will save the game to 'save0' after loading, for q2 compat +'spmap' is for q3 and sets 'gametype' to '2', otherwise identical to 'map'. all other map commands will reset it to '0' if its '2' at the time. ====================== */ void SV_Map_f (void) @@ -437,6 +447,7 @@ void SV_Map_f (void) qboolean cinematic = false; qboolean waschangelevel = false; qboolean wasspmap = false; + qboolean wasgamemap = false; int i; char *startspot; @@ -463,6 +474,7 @@ void SV_Map_f (void) waschangelevel = !strcmp(Cmd_Argv(0), "changelevel"); wasspmap = !strcmp(Cmd_Argv(0), "spmap"); + wasgamemap = !strcmp(Cmd_Argv(0), "gamemap"); if (strcmp(level, ".")) //restart current { @@ -660,6 +672,11 @@ void SV_Map_f (void) else Cvar_Set(nsv, ""); } + + if (wasgamemap) + { + SV_Savegame("s0"); + } } void SV_KillServer_f(void) diff --git a/engine/server/sv_ents.c b/engine/server/sv_ents.c index 8fd725941..fe6316998 100644 --- a/engine/server/sv_ents.c +++ b/engine/server/sv_ents.c @@ -211,12 +211,12 @@ void SV_EmitNailUpdate (sizebuf_t *msg, qboolean recorder) p = (int)(16*ent->v->angles[0]/360)&15; yaw = (int)(256*ent->v->angles[1]/360)&255; - bits[0] = x; - bits[1] = (x>>8) | (y<<4); - bits[2] = (y>>4); - bits[3] = z; - bits[4] = (z>>8) | (p<<4); - bits[5] = yaw; + bits[0] = x & 0xff; + bits[1] = ((x>>8) | (y<<4)) & 0xff; + bits[2] = (y>>4) & 0xff; + bits[3] = z & 0xff; + bits[4] = ((z>>8) | (p<<4)) & 0xff; + bits[5] = yaw & 0xff; for (i=0 ; i<6 ; i++) MSG_WriteByte (msg, bits[i]); diff --git a/engine/server/sv_phys.c b/engine/server/sv_phys.c index 0f69d53d9..612615b83 100644 --- a/engine/server/sv_phys.c +++ b/engine/server/sv_phys.c @@ -2184,7 +2184,7 @@ qboolean SV_Physics (void) SV_RunEntity (ent); SV_RunNewmis (); - if (ent->solidtype != ent->v->solid && !ent->isfree) + if (((!ent->solidtype) != (!(qbyte)ent->v->solid)) && !ent->isfree) { Con_DPrintf("Entity \"%s\" improperly changed solid type\n", PR_GetString(svprogfuncs, ent->v->classname)); World_LinkEdict (&sv.world, (wedict_t*)ent, true); // a change of solidity should always relink the edict. someone messed up. diff --git a/engine/server/sv_user.c b/engine/server/sv_user.c index bf5fef9d3..d71e98b51 100644 --- a/engine/server/sv_user.c +++ b/engine/server/sv_user.c @@ -945,7 +945,7 @@ void SV_Soundlist_f (void) MSG_WriteByte (&host_client->netchan.message, 0); // next msg - MSG_WriteByte (&host_client->netchan.message, n); + MSG_WriteByte (&host_client->netchan.message, n & 0xff); } /* @@ -1079,7 +1079,7 @@ void SV_Modellist_f (void) MSG_WriteByte (&host_client->netchan.message, 0); // next msg - MSG_WriteByte (&host_client->netchan.message, n); + MSG_WriteByte (&host_client->netchan.message, n & 0xff); } /* @@ -1706,6 +1706,8 @@ void SV_Begin_f (void) if (host_client->istobeloaded) sendangles = true; + if (host_client->protocol == SCP_QUAKE2) + sendangles = false; for (split = host_client; split; split = split->controlled) @@ -5026,7 +5028,7 @@ void AddLinksToPmove ( edict_t *player, areanode_t *node ) pl = EDICT_TO_PROG(svprogfuncs, player); // touch linked edicts - for (l = node->solid_edicts.next ; l != &node->solid_edicts ; l = next) + for (l = node->edicts.next ; l != &node->edicts ; l = next) { next = l->next; check = (edict_t*)EDICT_FROM_AREA(l); @@ -5076,7 +5078,7 @@ void AddLinksToPmove ( edict_t *player, areanode_t *node ) } } if (player->v->mins[2] != 24) //crouching/dead - for (l = node->trigger_edicts.next ; l != &node->trigger_edicts ; l = next) + for (l = node->edicts.next ; l != &node->edicts ; l = next) { next = l->next; check = (edict_t*)EDICT_FROM_AREA(l); diff --git a/engine/server/svmodel.c b/engine/server/svmodel.c index 9932442e6..98f19b445 100644 --- a/engine/server/svmodel.c +++ b/engine/server/svmodel.c @@ -1227,7 +1227,8 @@ Mod_LoadClipnodes */ qboolean Mod_LoadClipnodes (lump_t *l) { - dclipnode_t *in, *out; + dclipnode_t *in; + mclipnode_t *out; int i, count; hull_t *hull; @@ -1346,7 +1347,7 @@ Deplicate the drawing hull structure as a clipping hull void Mod_MakeHull0 (void) { mnode_t *in, *child; - dclipnode_t *out; + mclipnode_t *out; int i, j, count; hull_t *hull; diff --git a/engine/server/svq3_game.c b/engine/server/svq3_game.c index 2d8eb955d..a9f1bfa01 100644 --- a/engine/server/svq3_game.c +++ b/engine/server/svq3_game.c @@ -8,17 +8,10 @@ float RadiusFromBounds (vec3_t mins, vec3_t maxs); #define USEBOTLIB -//#define BOTLIB_STATIC #ifdef USEBOTLIB - -#ifdef _WIN32 -#define QDECL __cdecl -#else -#define QDECL -#endif #define fileHandle_t int #define fsMode_t int #define pc_token_t void @@ -342,7 +335,7 @@ static void Q3G_LinkEntity(q3sharedEntity_t *ent) break; // crosses the node } // link it in - InsertLinkBefore((link_t *)&sent->area, &node->solid_edicts); + InsertLinkBefore((link_t *)&sent->area, &node->edicts); } static int SVQ3_EntitiesInBoxNode(areanode_t *node, vec3_t mins, vec3_t maxs, int *list, int maxcount) @@ -354,7 +347,7 @@ static int SVQ3_EntitiesInBoxNode(areanode_t *node, vec3_t mins, vec3_t maxs, in int linkcount = 0; //work out who they are first. - for (l = node->solid_edicts.next ; l != &node->solid_edicts ; l = next) + for (l = node->edicts.next ; l != &node->edicts ; l = next) { if (maxcount == linkcount) return linkcount; @@ -388,6 +381,7 @@ static int SVQ3_EntitiesInBox(vec3_t mins, vec3_t maxs, int *list, int maxcount) return SVQ3_EntitiesInBoxNode(sv.world.areanodes, mins, maxs, list, maxcount); } +#define ENTITYNUM_NONE (MAX_GENTITIES-1) #define ENTITYNUM_WORLD (MAX_GENTITIES-2) static void SVQ3_Trace(q3trace_t *result, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int entnum, int contentmask) { @@ -408,7 +402,7 @@ static void SVQ3_Trace(q3trace_t *result, vec3_t start, vec3_t mins, vec3_t maxs result->allsolid = tr.allsolid; result->contents = tr.contents; VectorCopy(tr.endpos, result->endpos); - result->entityNum = ENTITYNUM_WORLD; + result->entityNum = (tr.fraction==1.0)?ENTITYNUM_NONE:ENTITYNUM_WORLD; result->fraction = tr.fraction; result->plane = tr.plane; result->startsolid = tr.startsolid; @@ -436,7 +430,7 @@ static void SVQ3_Trace(q3trace_t *result, vec3_t start, vec3_t mins, vec3_t maxs else if ( entnum != ENTITYNUM_WORLD ) { ourowner = GENTITY_FOR_NUM(entnum)->r.ownerNum; - if (ourowner == ENTITYNUM_WORLD) + if (ourowner == ENTITYNUM_NONE) ourowner = -1; } else @@ -2715,7 +2709,7 @@ static qboolean SVQ3_Netchan_Process(client_t *client) net_message.packing = SZ_RAWBYTES; // calculate bitmask - bitmask = serverid ^ lastSequence ^ client->challenge; + bitmask = (serverid ^ lastSequence ^ client->challenge) & 0xff; string = client->server_commands[lastServerCommandNum & TEXTCMD_MASK]; #ifndef Q3_NOENCRYPT @@ -2748,7 +2742,7 @@ void SVQ3_Netchan_Transmit(client_t *client, int length, qbyte *data) char *string; // calculate bitmask - bitmask = client->netchan.outgoing_sequence ^ client->challenge; + bitmask = (client->netchan.outgoing_sequence ^ client->challenge) & 0xff; string = client->last_client_command; #ifndef Q3_NOENCRYPT @@ -3210,6 +3204,7 @@ int SVQ3_AddBot(void) cl->challenge = 0; cl->userid = (cl - svs.clients)+1; cl->state = cs_spawned; + memset(&cl->netchan.remote_address, 0, sizeof(cl->netchan.remote_address)); return cl - svs.clients; } diff --git a/engine/server/world.c b/engine/server/world.c index c8942d32e..5fa2590d3 100644 --- a/engine/server/world.c +++ b/engine/server/world.c @@ -58,7 +58,7 @@ HULL BOXES static hull_t box_hull; -static dclipnode_t box_clipnodes[6]; +static mclipnode_t box_clipnodes[6]; static mplane_t box_planes[6]; /* @@ -141,8 +141,7 @@ static areanode_t *World_CreateAreaNode (world_t *w, int depth, vec3_t mins, vec anode = &w->areanodes[w->numareanodes]; w->numareanodes++; - ClearLink (&anode->trigger_edicts); - ClearLink (&anode->solid_edicts); + ClearLink (&anode->edicts); if (depth == AREA_DEPTH) { @@ -225,7 +224,7 @@ void World_TouchLinks (world_t *w, wedict_t *ent, areanode_t *node) int linkcount = 0, ln; //work out who they are first. - for (l = node->trigger_edicts.next ; l != &node->trigger_edicts ; l = next) + for (l = node->edicts.next ; l != &node->edicts ; l = next) { if (linkcount == MAX_NODELINKS) break; @@ -495,10 +494,7 @@ void World_LinkEdict (world_t *w, wedict_t *ent, qboolean touch_triggers) // link it in - if (ent->v->solid == SOLID_TRIGGER || ent->v->solid == SOLID_LADDER) - InsertLinkBefore (&ent->area, &node->trigger_edicts); - else - InsertLinkBefore (&ent->area, &node->solid_edicts); + InsertLinkBefore (&ent->area, &node->edicts); // if touch_triggers, touch all entities at this node and decend for more if (touch_triggers) @@ -685,11 +681,7 @@ void VARGS WorldQ2_LinkEdict(world_t *w, q2edict_t *ent) } // link it in - if (ent->solid == Q2SOLID_TRIGGER) - InsertLinkBefore (&ent->area, &node->trigger_edicts); - else - InsertLinkBefore (&ent->area, &node->solid_edicts); - + InsertLinkBefore (&ent->area, &node->edicts); } void WorldQ2_Q1BSP_LinkEdict(world_t *w, q2edict_t *ent) @@ -862,11 +854,8 @@ void WorldQ2_Q1BSP_LinkEdict(world_t *w, q2edict_t *ent) break; // crosses the node } - // link it in - if (ent->solid == Q2SOLID_TRIGGER) - InsertLinkBefore (&ent->area, &node->trigger_edicts); - else - InsertLinkBefore (&ent->area, &node->solid_edicts); + // link it in + InsertLinkBefore (&ent->area, &node->edicts); } #endif @@ -1127,6 +1116,7 @@ q2edict_t **area_q2list; int area_count, area_maxcount; int area_type; #define AREA_SOLID 1 +#define AREA_TRIGGER 2 static void World_AreaEdicts_r (areanode_t *node) { link_t *l, *next, *start; @@ -1136,10 +1126,7 @@ static void World_AreaEdicts_r (areanode_t *node) count = 0; // touch linked edicts - if (area_type == AREA_SOLID) - start = &node->solid_edicts; - else - start = &node->trigger_edicts; + start = &node->edicts; for (l=start->next ; l != start ; l = next) { @@ -1148,6 +1135,11 @@ static void World_AreaEdicts_r (areanode_t *node) if (check->v->solid == SOLID_NOT) continue; // deactivated + + /*q2 still has solid/trigger lists, emulate that here*/ + if ((check->v->solid == SOLID_TRIGGER) != (area_type == AREA_TRIGGER)) + continue; + if (check->v->absmin[0] > area_maxs[0] || check->v->absmin[1] > area_maxs[1] || check->v->absmin[2] > area_maxs[2] @@ -1206,10 +1198,7 @@ static void WorldQ2_AreaEdicts_r (areanode_t *node) count = 0; // touch linked edicts - if (area_type == AREA_SOLID) - start = &node->solid_edicts; - else - start = &node->trigger_edicts; + start = &node->edicts; for (l=start->next ; l != start ; l = next) { @@ -1228,6 +1217,11 @@ static void WorldQ2_AreaEdicts_r (areanode_t *node) if (check->solid == Q2SOLID_NOT) continue; // deactivated + + /*q2 still has solid/trigger lists, emulate that here*/ + if ((check->solid == Q2SOLID_TRIGGER) != (area_type == AREA_TRIGGER)) + continue; + if (check->absmin[0] > area_maxs[0] || check->absmin[1] > area_maxs[1] || check->absmin[2] > area_maxs[2] @@ -1470,73 +1464,8 @@ static void World_ClipToLinks (world_t *w, areanode_t *node, moveclip_t *clip) wedict_t *touch; trace_t trace; - if (clip->type & MOVE_TRIGGERS) - { - for (l = node->trigger_edicts.next ; l != &node->trigger_edicts ; l = next) - { - next = l->next; - touch = EDICT_FROM_AREA(l); - if (!((int)touch->v->flags & FL_FINDABLE_NONSOLID)) - continue; - if (touch->v->solid != SOLID_TRIGGER) - continue; - if (touch == clip->passedict) - continue; - - if (clip->type & MOVE_NOMONSTERS && touch->v->solid != SOLID_BSP) - continue; - - if (clip->passedict) - { - /* These can never happen, touch is a SOLID_TRIGGER - // don't clip corpse against character - if (clip->passedict->v->solid == SOLID_CORPSE && (touch->v->solid == SOLID_SLIDEBOX || touch->v->solid == SOLID_CORPSE)) - continue; - // don't clip character against corpse - if (clip->passedict->v->solid == SOLID_SLIDEBOX && touch->v->solid == SOLID_CORPSE) - continue; - */ - if (!((int)clip->passedict->xv->dimension_hit & (int)touch->xv->dimension_solid)) - continue; - } - - if (clip->boxmins[0] > touch->v->absmax[0] - || clip->boxmins[1] > touch->v->absmax[1] - || clip->boxmins[2] > touch->v->absmax[2] - || clip->boxmaxs[0] < touch->v->absmin[0] - || clip->boxmaxs[1] < touch->v->absmin[1] - || clip->boxmaxs[2] < touch->v->absmin[2] ) - continue; - - if (clip->passedict && clip->passedict->v->size[0] && !touch->v->size[0]) - continue; // points never interact - - // might intersect, so do an exact clip - if (clip->trace.allsolid) - return; - if (clip->passedict) - { - if ((wedict_t*)PROG_TO_EDICT(w->progs, touch->v->owner) == clip->passedict) - continue; // don't clip against own missiles - if ((wedict_t*)PROG_TO_EDICT(w->progs, clip->passedict->v->owner) == touch) - continue; // don't clip against owner - } - - if ((int)touch->v->flags & FL_MONSTER) - trace = World_ClipMoveToEntity (w, touch, touch->v->origin, clip->start, clip->mins2, clip->maxs2, clip->end, clip->hullnum, clip->type & MOVE_HITMODEL); - else - trace = World_ClipMoveToEntity (w, touch, touch->v->origin, clip->start, clip->mins, clip->maxs, clip->end, clip->hullnum, clip->type & MOVE_HITMODEL); - if (trace.allsolid || trace.startsolid || - trace.fraction < clip->trace.fraction) - { - trace.ent = touch; - clip->trace = trace; - } - } - } - // touch linked edicts - for (l = node->solid_edicts.next ; l != &node->solid_edicts ; l = next) + for (l = node->edicts.next ; l != &node->edicts ; l = next) { next = l->next; touch = EDICT_FROM_AREA(l); @@ -1544,10 +1473,14 @@ static void World_ClipToLinks (world_t *w, areanode_t *node, moveclip_t *clip) continue; if (touch == clip->passedict) continue; + + /*if its a trigger, we only clip against it if the flags are aligned*/ if (touch->v->solid == SOLID_TRIGGER || touch->v->solid == SOLID_LADDER) { - Con_Printf ("Trigger (%s) in clipping list\n", PR_GetString(w->progs, touch->v->classname)); - continue; + if (!(clip->type & MOVE_TRIGGERS)) + continue; + if (!((int)touch->v->flags & FL_FINDABLE_NONSOLID)) + continue; } if (clip->type & MOVE_LAGGED) @@ -1627,7 +1560,7 @@ static void WorldQ2_ClipToLinks (world_t *w, areanode_t *node, moveclip_t *clip) trace_t trace; // touch linked edicts - for (l = node->solid_edicts.next ; l != &node->solid_edicts ; l = next) + for (l = node->edicts.next ; l != &node->edicts ; l = next) { next = l->next; touch = Q2EDICT_FROM_AREA(l);