diff --git a/engine/client/cl_input.c b/engine/client/cl_input.c index b28a011b2..2ed59a36b 100644 --- a/engine/client/cl_input.c +++ b/engine/client/cl_input.c @@ -927,9 +927,8 @@ unsigned long _stdcall CL_IndepPhysicsThread(void *param) { EnterCriticalSection(&indepcriticialsection); time = Sys_DoubleTime(); - host_frametime = time - lasttime; + CL_SendCmd(time - lasttime); lasttime = time; - CL_SendCmd(); LeaveCriticalSection(&indepcriticialsection); fps = cl_netfps.value; @@ -982,7 +981,7 @@ CL_SendCmd */ usercmd_t independantphysics[MAX_SPLITS]; vec3_t accum[MAX_SPLITS]; -void CL_SendCmd (void) +void CL_SendCmd (float frametime) { sizebuf_t buf; qbyte data[512]; @@ -1013,7 +1012,7 @@ void CL_SendCmd (void) usercmd_t ncmd; memset(&ncmd, 0, sizeof(ncmd)); - ncmd.msec = host_frametime*1000; + ncmd.msec = frametime*1000; CL_BaseMove (&ncmd, 0); @@ -1024,7 +1023,7 @@ void CL_SendCmd (void) if (cl.spectator) Cam_Track(0, &ncmd); - CL_FinishMove(&ncmd, (int)(host_frametime*1000), 0); + CL_FinishMove(&ncmd, (int)(frametime*1000), 0); Cam_FinishMove(0, &ncmd); @@ -1056,7 +1055,7 @@ void CL_SendCmd (void) cmd = &cl.frames[i].cmd[0]; memset(cmd, 0, sizeof(*cmd)); - cmd->msec = host_frametime*1000; + cmd->msec = frametime*1000; independantphysics[0].msec = 0; // get basic movement from keyboard @@ -1069,7 +1068,7 @@ void CL_SendCmd (void) if (cl.spectator) Cam_Track(0, cmd); - CL_FinishMove(cmd, (int)(host_frametime*1000), 0); + CL_FinishMove(cmd, (int)(frametime*1000), 0); Cam_FinishMove(0, cmd); @@ -1087,7 +1086,7 @@ void CL_SendCmd (void) } #endif - msecs += host_frametime*1000; + msecs += frametime*1000; // Con_Printf("%f\n", msecs); if (msecs>1000) //come on... That's just stupid. @@ -1345,7 +1344,7 @@ void CL_SendCmd (void) //shamelessly stolen from fuhquake if (cl_c2spps.value>0) { - pps_balance += host_frametime; + pps_balance += frametime; // never drop more than 2 messages in a row -- that'll cause PL // and don't drop if one of the last two movemessages have an impulse if (pps_balance > 0 || dropcount >= 2 || dontdrop) diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index ac6797dbf..5d5e18d80 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -1289,6 +1289,12 @@ void CL_FullServerinfo_f (void) } CL_CheckServerInfo(); + cl.gamespeed = atof(Info_ValueForKey(cl.serverinfo, "*gamespeed"))/100.f; + if (cl.gamespeed < 0.1) + cl.gamespeed = 1; + + cl.csqcdebug = atoi(Info_ValueForKey(cl.serverinfo, "*csqcdebug")); + #ifdef CSQC_DAT p = Info_ValueForKey(cl.serverinfo, "*csprogs"); if (*p) //only allow csqc if the server says so, and the 'checksum' matches. @@ -2249,9 +2255,6 @@ void CL_Init (void) Info_SetValueForStarKey (cls.userinfo, "*ver", st, MAX_INFO_STRING); InitValidation(); -#ifdef CLPROGS - CLPR_Init(); -#endif CL_InitInput (); CL_InitTEnts (); @@ -2264,7 +2267,9 @@ void CL_Init (void) // register our commands // CLSCR_Init(); - +#ifdef CSQC_DAT + CSQC_RegisterCvarsAndThings(); +#endif Cvar_Register (&host_speeds, cl_controlgroup); Cvar_Register (&developer, cl_controlgroup); @@ -2587,12 +2592,15 @@ void Host_Frame (float time) static double time3 = 0; int pass1, pass2, pass3; // float fps; + float realframetime; RSpeedLocals(); if (setjmp (host_abort) ) return; // something bad happened, or the server disconnected + realframetime = time; + #if defined(WINAVI) && !defined(NOMEDIA) if (cls.demoplayback && recordingdemo && recordavi_frametime>0.01) time = recordavi_frametime; @@ -2606,6 +2614,9 @@ void Host_Frame (float time) SV_Frame(time); RSpeedEnd(RSPEED_SERVER); #endif + if (cl.gamespeed<0.1) + cl.gamespeed = 1; + time *= cl.gamespeed; #ifdef WEBCLIENT FTP_ClientThink(); @@ -2722,7 +2733,7 @@ void Host_Frame (float time) { extern qboolean runningindepphys; if (!runningindepphys) - CL_SendCmd (); + CL_SendCmd (realframetime); if (cls.state == ca_onserver && cl.validsequence && cl.worldmodel) { // first update is the final signon stage @@ -2918,15 +2929,15 @@ void Host_Init (quakeparms_t *parms) Hunk_AllocName (0, "-HOST_HUNKLEVEL-"); host_hunklevel = Hunk_LowMark (); -BZ_CheckAllSentinals(); + R_SetRenderer(0);//set the renderer stuff to 'none'... host_initialized = true; Cmd_StuffCmds(); -BZ_CheckAllSentinals(); + Cbuf_Execute (); //if the server initialisation causes a problem, give it a place to abort to -BZ_CheckAllSentinals(); + //assuming they didn't use any waits in thier config (fools) //the configs should be fully loaded. //so convert the backwards compable commandline parameters in cvar sets. @@ -2935,7 +2946,7 @@ BZ_CheckAllSentinals(); Cvar_Set(Cvar_FindVar("vid_fullscreen"), "0"); if (COM_CheckParm ("-fullscreen")) Cvar_Set(Cvar_FindVar("vid_fullscreen"), "1"); -BZ_CheckAllSentinals(); + if ((i = COM_CheckParm ("-width"))) //width on it's own also sets height { Cvar_Set(Cvar_FindVar("vid_width"), com_argv[i+1]); diff --git a/engine/client/cl_parse.c b/engine/client/cl_parse.c index a6abd0dfe..f11538665 100644 --- a/engine/client/cl_parse.c +++ b/engine/client/cl_parse.c @@ -1857,7 +1857,7 @@ void CL_ParseModellist (qboolean lots) void CL_ProcessUserInfo (int slot, player_info_t *player); void CLQ2_ParseClientinfo(int i, char *s) { - char *skin, *model, *name; + char *model, *name; player_info_t *player; //s contains "name\model/skin" @@ -1877,7 +1877,7 @@ void CLQ2_ParseClientinfo(int i, char *s) name = "Unnammed"; model = "male"; } - +#if 0 skin = strchr(model, '/'); if (skin) { @@ -1886,9 +1886,16 @@ void CLQ2_ParseClientinfo(int i, char *s) } else skin = ""; - Info_SetValueForKey(player->userinfo, "name", name, MAX_INFO_STRING); Info_SetValueForKey(player->userinfo, "model", model, MAX_INFO_STRING); Info_SetValueForKey(player->userinfo, "skin", skin, MAX_INFO_STRING); +#else + Info_SetValueForKey(player->userinfo, "skin", model, MAX_INFO_STRING); +#endif + Info_SetValueForKey(player->userinfo, "name", name, MAX_INFO_STRING); + + cl.players[i].userid = i; + cl.players[i].bottomcolor = 1; + cl.players[i].topcolor = 1; CL_ProcessUserInfo (i, player); } diff --git a/engine/client/cl_pred.c b/engine/client/cl_pred.c index db7d22c1f..83f6ef2b6 100644 --- a/engine/client/cl_pred.c +++ b/engine/client/cl_pred.c @@ -428,7 +428,7 @@ void CL_PredictUsercmd (int pnum, player_state_t *from, player_state_t *to, user player_mins[2] = 0; } - PM_PlayerMove (); + PM_PlayerMove (cl.gamespeed); to->waterjumptime = pmove.waterjumptime; to->jump_held = pmove.jump_held; diff --git a/engine/client/client.h b/engine/client/client.h index 9067a7d56..7e07dafc3 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -386,6 +386,9 @@ typedef struct int fpd; int servercount; // server identification for prespawns + float gamespeed; + qboolean csqcdebug; + char serverinfo[MAX_SERVERINFO_STRING]; int parsecount; // server message counter @@ -489,10 +492,6 @@ typedef struct // all player information player_info_t players[MAX_CLIENTS]; -#ifdef CLPROGS - struct edict_s *edicts; - int num_edicts; -#endif downloadlist_t *downloadlist; downloadlist_t *faileddownloads; @@ -634,7 +633,7 @@ extern kbutton_t in_speed; extern float in_sensitivityscale; void CL_InitInput (void); -void CL_SendCmd (void); +void CL_SendCmd (float frametime); void CL_SendMove (usercmd_t *cmd); #ifdef NQPROT void CL_ParseTEnt (qboolean nqprot); diff --git a/engine/client/clq2_ents.c b/engine/client/clq2_ents.c index c23ec21c0..63d5e10cd 100644 --- a/engine/client/clq2_ents.c +++ b/engine/client/clq2_ents.c @@ -2,6 +2,7 @@ #include "particles.h" #ifdef Q2CLIENT +#include "shader.h" extern cvar_t r_drawviewmodel; @@ -1438,10 +1439,10 @@ void CLQ2_AddPacketEntities (q2frame_t *frame) player = &cl.players[s1->skinnum%MAX_CLIENTS]; ent.model = player->model; - if (!ent.model) + if (!ent.model || ent.model->needload) //we need to do better than this { ent.model = Mod_ForName(va("players/%s/tris.md2", Info_ValueForKey(player->userinfo, "model")), false); - if (!ent.model) + if (!ent.model || ent.model->needload) ent.model = Mod_ForName("players/male/tris.md2", false); } ent.scoreboard = player; @@ -1529,12 +1530,11 @@ void CLQ2_AddPacketEntities (q2frame_t *frame) } } - ent.angles[0]*=-1; + ent.angles[0]*=-1; //q2 has it fixed. - if (s1->number == cl.playernum[0]+1) + if (s1->number == cl.playernum[0]+1) //woo! this is us! { ent.flags |= Q2RF_VIEWERMODEL; // only draw from mirrors - // FIXME: still pass to refresh if (effects & Q2EF_FLAG1) V_AddLight (ent.origin, 225, 0.2, 0.05, 0.05); @@ -1544,8 +1544,6 @@ void CLQ2_AddPacketEntities (q2frame_t *frame) V_AddLight (ent.origin, 225, 0.2, 0.2, 0.0); //PGM else if (effects & Q2EF_TRACKERTRAIL) //PGM V_AddLight (ent.origin, 225, -0.2, -0.2, -0.2); //PGM - - continue; } // if set to invisible, skip @@ -1589,7 +1587,7 @@ void CLQ2_AddPacketEntities (q2frame_t *frame) // all of the solo colors are fine. we need to catch any of the combinations that look bad // (double & half) and turn them into the appropriate color, and make double/quad something special -/* if (renderfx & Q2RF_SHELL_HALF_DAM) + if (renderfx & Q2RF_SHELL_HALF_DAM) { { @@ -1617,13 +1615,22 @@ void CLQ2_AddPacketEntities (q2frame_t *frame) else renderfx |= Q2RF_SHELL_GREEN; } - }*/ + } // pmm ent.flags = renderfx | Q2RF_TRANSLUCENT; ent.alpha = 0.30; - ent.fatness = 10; + ent.fatness = 1; +#ifdef Q3SHADERS + //fixme: this is woefully gl specific. :( + ent.shaderRGBA[0] = (!!(renderfx & Q2RF_SHELL_RED)) * 255; + ent.shaderRGBA[1] = (!!(renderfx & Q2RF_SHELL_GREEN)) * 255; + ent.shaderRGBA[2] = (!!(renderfx & Q2RF_SHELL_BLUE)) * 255; + ent.shaderRGBA[3] = ent.alpha*255; + ent.forcedshader = R_RegisterCustom("q2/shell", Shader_DefaultSkinShell); +#endif V_AddLerpEntity (&ent); } + ent.forcedshader = NULL; // ent.skin = NULL; // never use a custom skin on others ent.skinnum = 0; diff --git a/engine/client/menu.h b/engine/client/menu.h index 505670724..e08498d3f 100644 --- a/engine/client/menu.h +++ b/engine/client/menu.h @@ -367,4 +367,4 @@ void MP_Keyup(int key); #define MGT_QUAKE1 0 #define MGT_HEXEN2 1 #define MGT_QUAKE2 2 -int M_GameType(void); \ No newline at end of file +int M_GameType(void); diff --git a/engine/client/pr_csqc.c b/engine/client/pr_csqc.c index 46cbcd773..6ebf1d432 100644 --- a/engine/client/pr_csqc.c +++ b/engine/client/pr_csqc.c @@ -10,6 +10,8 @@ progfuncs_t *csqcprogs; unsigned int csqcchecksum; +cvar_t pr_csmaxedicts = {"pr_csmaxedicts", "3072"}; + #define csqcglobals \ globalfunction(init_function, "CSQC_Init"); \ globalfunction(shutdown_function, "CSQC_Shutdown"); \ @@ -1345,7 +1347,7 @@ qboolean CSQC_Init (unsigned int checksum) memset(csqcent, 0, sizeof(csqcent)); - csqcentsize = PR_InitEnts(csqcprogs, 3072); + csqcentsize = PR_InitEnts(csqcprogs, pr_csmaxedicts.value); CSQC_FindGlobals(); @@ -1363,6 +1365,11 @@ qboolean CSQC_Init (unsigned int checksum) return true; //success! } +void CSQC_RegisterCvarsAndThings(void) +{ + Cvar_Register(&pr_csmaxedicts, "csqc"); +} + qboolean CSQC_DrawView(void) { if (!csqcg.draw_function || !csqcprogs || !cl.worldmodel) @@ -1421,6 +1428,8 @@ void CSQC_ParseEntities(void) csqcedict_t *ent; unsigned short entnum; void *pr_globals; + int packetsize; + int packetstart; if (!csqcprogs) Host_EndGame("CSQC needs to be initialized for this server.\n"); @@ -1463,6 +1472,12 @@ void CSQC_ParseEntities(void) if (entnum >= MAX_EDICTS) Host_EndGame("CSQC recieved too many edicts!\n"); + if (cl.csqcdebug) + { + packetsize = MSG_ReadShort(); + packetstart = msg_readcount; + } + ent = csqcent[entnum]; if (!ent) { @@ -1475,6 +1490,25 @@ void CSQC_ParseEntities(void) *csqcg.self = EDICT_TO_PROG(csqcprogs, (void*)ent); PR_ExecuteProgram(csqcprogs, csqcg.ent_update); + + if (cl.csqcdebug) + { + if (msg_readcount != packetstart+packetsize) + { + if (msg_readcount > packetstart+packetsize) + Con_Printf("CSQC overread entity %i. Size %i, read %i\n", entnum, packetsize, msg_readcount - packetsize); + else + Con_Printf("CSQC underread entity %i. Size %i, read %i\n", entnum, packetsize, msg_readcount - packetsize); + Con_Printf("First byte is %i\n", net_message.data[msg_readcount]); +#ifndef CLIENTONLY + if (sv.state) + { + Con_Printf("Server classname: \"%s\"\n", svprogfuncs->stringtable+EDICT_NUM(svprogfuncs, entnum)->v.classname); + } +#endif + } + msg_readcount = packetstart+packetsize; //leetism. + } } } } diff --git a/engine/client/quakedef.h b/engine/client/quakedef.h index c6514bbe1..d27580623 100644 --- a/engine/client/quakedef.h +++ b/engine/client/quakedef.h @@ -21,8 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "bothdefs.h" //first thing included by ALL files. -#pragma message("building quakedef.h") - #if _MSC_VER #define MSVCDISABLEWARNINGS #endif diff --git a/engine/client/sbar.c b/engine/client/sbar.c index fe7d089f9..8daf78b83 100644 --- a/engine/client/sbar.c +++ b/engine/client/sbar.c @@ -2352,41 +2352,3 @@ void Sbar_FinaleOverlay (void) Draw_TransPic ( (vid.width-pic->width)/2, 16, pic); } - - - - - -#ifdef CLPROGS -void PF_sbardrawsubpic(progfuncs_t *prinst, struct globalvars_s *pr_globals) -{ - Sbar_DrawSubPic(G_FLOAT(OFS_PARM0), G_FLOAT(OFS_PARM1), Draw_PicFromWad(PR_GetStringOfs(prinst, OFS_PARM2)), G_FLOAT(OFS_PARM3), G_FLOAT(OFS_PARM4), G_FLOAT(OFS_PARM5), G_FLOAT(OFS_PARM6)); -} -void PF_sbardrawpic(progfuncs_t *prinst, struct globalvars_s *pr_globals) -{ - Sbar_DrawPic(G_FLOAT(OFS_PARM0), G_FLOAT(OFS_PARM1), Draw_PicFromWad(PR_GetStringOfs(prinst, OFS_PARM2))); -} -void PF_sbardrawnum(progfuncs_t *prinst, struct globalvars_s *pr_globals) -{ - Sbar_DrawNum(G_FLOAT(OFS_PARM0), G_FLOAT(OFS_PARM1), G_FLOAT(OFS_PARM2), G_FLOAT(OFS_PARM3), G_FLOAT(OFS_PARM4)); -} -void PF_sbardrawint(progfuncs_t *prinst, struct globalvars_s *pr_globals) -{ - Sbar_DrawNum(G_FLOAT(OFS_PARM0), G_FLOAT(OFS_PARM1), G_INT(OFS_PARM2), G_FLOAT(OFS_PARM3), G_FLOAT(OFS_PARM4)); -} -void PF_getstats(progfuncs_t *prinst, struct globalvars_s *pr_globals) -{ - G_FLOAT(OFS_RETURN) = cl.stats[(int)G_FLOAT(OFS_PARM0)]; -} -void PF_getscreendim(progfuncs_t *prinst, struct globalvars_s *pr_globals) -{ - if (!G_FLOAT(OFS_PARM0)) - G_FLOAT(OFS_RETURN) = vid.width; - else - G_FLOAT(OFS_RETURN) = vid.height; -} -void PF_getstatsi(progfuncs_t *prinst, struct globalvars_s *pr_globals) -{ - G_INT(OFS_RETURN) = cl.stats[(int)G_FLOAT(OFS_PARM0)]; -} -#endif diff --git a/engine/client/skin.c b/engine/client/skin.c index 59b870e6c..c1399deae 100644 --- a/engine/client/skin.c +++ b/engine/client/skin.c @@ -149,7 +149,10 @@ void Skin_Find (player_info_t *sc) if (s) { *s = '\0'; - model = Mod_ForName(va("models/players/%s.mdl", name), false); + if (cls.q2server) + model = Mod_ForName(va("players/%s/tris.mdl", name), false); + else + model = Mod_ForName(va("models/players/%s.mdl", name), false); if (model->type == mod_dummy) model = NULL; *s = '/'; @@ -231,7 +234,6 @@ qbyte *Skin_Cache8 (skin_t *skin) // // load the pic from disk // -// sprintf (name, "players/male/%s.pcx", skin->name); if (strchr(skin->name, ' ')) //see if it's actually three colours { qbyte bv; @@ -260,7 +262,10 @@ qbyte *Skin_Cache8 (skin_t *skin) return out; } - sprintf (name, "skins/%s.pcx", skin->name); + if (cls.q2server) + sprintf (name, "players/%s.pcx", skin->name); + else + sprintf (name, "skins/%s.pcx", skin->name); raw = COM_LoadTempFile (name); if (!raw) { @@ -291,21 +296,29 @@ qbyte *Skin_Cache8 (skin_t *skin) Con_Printf ("Bad skin %s\n", name); return NULL; } - skin->width = 320; - skin->height = 200; + if (qrenderer == QR_SOFTWARE) + { + skin->width = 320; + skin->height = 200; + } + else + { + skin->width = pcx->xmax+1; + skin->height = pcx->ymax; + } skin->cachedbpp = 8; pcx->xmax = (unsigned short)LittleShort(pcx->xmax); pcx->ymax = (unsigned short)LittleShort(pcx->ymax); - out = Cache_Alloc (&skin->cache, 320*200, skin->name); + out = Cache_Alloc (&skin->cache, skin->width*skin->height, skin->name); if (!out) Sys_Error ("Skin_Cache: couldn't allocate"); pix = out; - memset (out, 0, 320*200); + memset (out, 0, skin->width*skin->height); - for (y=0 ; yymax ; y++, pix += 320) + for (y=0 ; yymax ; y++, pix += skin->width) { for (x=0 ; x<=pcx->xmax ; ) { diff --git a/engine/client/sys_linux.c b/engine/client/sys_linux.c index 9dc0c83de..7562afbe2 100644 --- a/engine/client/sys_linux.c +++ b/engine/client/sys_linux.c @@ -309,41 +309,6 @@ void Sys_EditFile(char *filename) } } -//1 if match -//FIXME: make windows like - *.* becomes * -int wildcmp(char *wild, char *string) { - char *cp, *mp; - - while ((*string) && (*wild != '*')) { - if ((*wild != *string) && (*wild != '?')) { - return 0; - } - wild++; - string++; - } - - while (*string) { - if (*wild == '*') { - if (!*++wild) { - return 1; - } - mp = wild; - cp = string+1; - } else if ((*wild == *string) || (*wild == '?')) { - wild++; - string++; - } else { - wild = mp; - string = cp++; - } - } - - while (*wild == '*') { - wild++; - } - return !*wild; -} - int Sys_EnumerateFiles (char *gpath, char *match, int (*func)(char *, int, void *), void *parm) { diff --git a/engine/client/sys_win.c b/engine/client/sys_win.c index 9e2e2dde6..4016b095e 100644 --- a/engine/client/sys_win.c +++ b/engine/client/sys_win.c @@ -357,40 +357,6 @@ qboolean Sys_remove (char *path) return true; } -//1 if match -int wildcmp(char *wild, char *string) { - char *cp=NULL, *mp=NULL; - - while ((*string) && (*wild != '*')) { - if ((*wild != *string) && (*wild != '?')) { - return 0; - } - wild++; - string++; - } - - while (*string) { - if (*wild == '*') { - if (!*++wild) { - return 1; - } - mp = wild; - cp = string+1; - } else if ((*wild == *string) || (*wild == '?')) { - wild++; - string++; - } else { - wild = mp; - string = cp++; - } - } - - while (*wild == '*') { - wild++; - } - return !*wild; -} - int Sys_EnumerateFiles (char *gpath, char *match, int (*func)(char *, int, void *), void *parm) { HANDLE r; diff --git a/engine/common/common.c b/engine/common/common.c index 77b3398f6..f3b18d535 100644 --- a/engine/common/common.c +++ b/engine/common/common.c @@ -332,38 +332,49 @@ char *Q_strlwr(char *s) return ret; } - -int Q_strwildcmp(char *s1, char *s2) //2 is wild +int wildcmp(char *wild, char *string) { - return !wildcmp(s1, s2); - while (1) + char *cp=NULL, *mp=NULL; + + while ((*string) && (*wild != '*')) { - if (!*s1 && !*s2) - return 0; //yay, they are equivalent - if (!*s1 || !*s2) - return -1; //one ended too soon. - - if (*s2 == '*') + if ((*wild != *string) && (*wild != '?')) { - s2++; - while (1) - { - if (!*s1 && *s2) - return -1; - if (*s1 == '.' || *s1 == '/' || !*s1) - break; - s1++; - } + return 0; + } + wild++; + string++; + } + + while (*string) + { + if (*wild == '*') + { + if (!*++wild) + { + return 1; + } + mp = wild; + cp = string+1; + } + else if ((*wild == *string) || (*wild == '?')) + { + wild++; + string++; } - else if (*s2 != *s1 && *s2 != '?') - return -1; else { - s1++; - s2++; + wild = mp; + string = cp++; } } + + while (*wild == '*') + { + wild++; + } + return !*wild; } int Q_atoi (char *str) @@ -3465,7 +3476,6 @@ qbyte *COM_LoadStackFile (char *path, void *buffer, int bufsize) } -int Q_strwildcmp(char *s1, char *s2); #ifdef ZLIB int COM_EnumerateZipFiles (zipfile_t *zip, char *match, int (*func)(char *, int, void *), void *parm); #endif @@ -3475,7 +3485,7 @@ int COM_EnumeratePackFiles (pack_t *zip, char *match, int (*func)(char *, int, v for (num = 0; num<(int)zip->numfiles; num++) { - if (!Q_strwildcmp(zip->files[num].name, match)) + if (wildcmp(zip->files[num].name, match)) { if (!func(zip->files[num].name, zip->files[num].filelen, parm)) return false; @@ -4030,14 +4040,13 @@ char *Com_ReadFileInZip(zipfile_t *zip, int index, char *buffer) return 0; } -int Q_strwildcmp(char *s1, char *s2); int COM_EnumerateZipFiles (zipfile_t *zip, char *match, int (*func)(char *, int, void *), void *parm) { int num; for (num = 0; num<(int)zip->numfiles; num++) { - if (!Q_strwildcmp(zip->files[num].name, match)) + if (wildcmp(zip->files[num].name, match)) { if (!func(zip->files[num].name, zip->files[num].filelen, parm)) return false; diff --git a/engine/common/common.h b/engine/common/common.h index 84b63baa6..c7c8857cd 100644 --- a/engine/common/common.h +++ b/engine/common/common.h @@ -165,6 +165,7 @@ void MSG_ReadData (void *data, int len); char *Q_strcpyline(char *out, char *in, int maxlen); //stops at '\n' (and '\r') char *Q_strlwr(char *str); +int wildcmp(char *wild, char *string); //1 if match #define Q_memset(d, f, c) memset((d), (f), (c)) #define Q_memcpy(d, s, c) memcpy((d), (s), (c)) diff --git a/engine/common/plugin.c b/engine/common/plugin.c index 74cfdecaa..aff8290b7 100644 --- a/engine/common/plugin.c +++ b/engine/common/plugin.c @@ -881,7 +881,7 @@ int Plug_Net_TCPListen(void *offset, unsigned int mask, const long *arg) if (((struct sockaddr_in*)&address)->sin_family == AF_INET && !((struct sockaddr_in*)&address)->sin_port) ((struct sockaddr_in*)&address)->sin_port = htons(localport); #ifdef IPPROTO_IPV6 - else if (((struct sockaddr_in*)&address)->sin6_family == AF_INET6 && !((struct sockaddr_in6*)&address)->sin6_port) + else if (((struct sockaddr_in6*)&address)->sin6_family == AF_INET6 && !((struct sockaddr_in6*)&address)->sin6_port) ((struct sockaddr_in6*)&address)->sin6_port = htons(localport); #endif diff --git a/engine/common/pmove.c b/engine/common/pmove.c index 2ffae1b5d..ac6fa4216 100644 --- a/engine/common/pmove.c +++ b/engine/common/pmove.c @@ -1004,9 +1004,9 @@ Numtouch and touchindex[] will be set if any of the physents were contacted during the move. ============= */ -void PM_PlayerMove (void) +void PM_PlayerMove (float gamespeed) { - frametime = pmove.cmd.msec * 0.001; + frametime = pmove.cmd.msec * 0.001*gamespeed; pmove.numtouch = 0; if (pmove.pm_type == PM_NONE || pmove.pm_type == PM_FREEZE) { diff --git a/engine/common/pmove.h b/engine/common/pmove.h index b6c67633e..c21f03cef 100644 --- a/engine/common/pmove.h +++ b/engine/common/pmove.h @@ -130,7 +130,7 @@ typedef struct { extern movevars_t movevars; extern playermove_t pmove; -void PM_PlayerMove (void); +void PM_PlayerMove (float gamespeed); void PM_Init (void); void PM_InitBoxHull (void); diff --git a/engine/common/qvm.c b/engine/common/qvm.c index 943f3cb0e..c961a188d 100644 --- a/engine/common/qvm.c +++ b/engine/common/qvm.c @@ -62,7 +62,7 @@ struct vm_s { void *hInst; // native - int (*vmMain)(int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6); + int (VARGS *vmMain)(int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6); }; diff --git a/engine/common/zone.c b/engine/common/zone.c index b12d61e4b..e1419743b 100644 --- a/engine/common/zone.c +++ b/engine/common/zone.c @@ -221,6 +221,7 @@ void BZ_CheckSentinals(void *c) #endif } +/* //revive this function each time you get memory corruption and need to trace it. void BZ_CheckAllSentinals(void) { zone_t *zone; @@ -244,6 +245,7 @@ void BZ_CheckAllSentinals(void) } } } +*/ void VARGS Z_FreeTags(int tag) { @@ -309,7 +311,6 @@ void *Z_BaseTagMalloc (int size, int tag, qboolean clear) #ifdef NAMEDMALLOCS strcpy((char *)(nt+1) + nt->size + ZONEDEBUG*2, buffer); #endif - BZ_CheckAllSentinals(); return buf; } void *VARGS Z_TagMalloc (int size, int tag) diff --git a/engine/ftequake/ftequake.dsp b/engine/ftequake/ftequake.dsp index 16bca835c..dbcbe7fe8 100644 --- a/engine/ftequake/ftequake.dsp +++ b/engine/ftequake/ftequake.dsp @@ -106,7 +106,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /G5 /ML /W3 /GX /ZI /Od /I "..\client" /I "../common" /I "../server" /I "../gl" /I "../sw" /I "../qclib" /I "../libs" /I "../libs/dxsdk7/include" /D "_DEBUG" /D "GLQUAKE" /D "WIN32" /D "_WINDOWS" /D "AVAIL_OGGVORBIS" /FR".\GLDebug/" /Fp".\GLDebug/qwcl.pch" /Yu"quakedef.h" /Fo".\GLDebug/" /Fd".\GLDebug/" /FD /c +# ADD CPP /nologo /G5 /ML /W3 /Gm- /Gi- /GX /ZI /Od /I "..\client" /I "../common" /I "../server" /I "../gl" /I "../sw" /I "../qclib" /I "../libs" /I "../libs/dxsdk7/include" /D "_DEBUG" /D "GLQUAKE" /D "WIN32" /D "_WINDOWS" /D "AVAIL_OGGVORBIS" /FR".\GLDebug/" /Fp".\GLDebug/qwcl.pch" /Yu"quakedef.h" /Fo".\GLDebug/" /Fd".\GLDebug/" /FD /c # SUBTRACT CPP /X # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 @@ -117,7 +117,8 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept -# ADD LINK32 comctl32.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib /nologo /subsystem:windows /pdb:none /debug /machine:I386 /out:"../../fteglqw_dbg.exe" +# ADD LINK32 comctl32.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib /nologo /subsystem:windows /debug /machine:I386 /out:"../../fteglqw_dbg.exe" +# SUBTRACT LINK32 /pdb:none !ELSEIF "$(CFG)" == "ftequake - Win32 GLRelease" @@ -145,6 +146,7 @@ BSC32=bscmake.exe LINK32=link.exe # ADD BASE LINK32 comctl32.lib ..\dxsdk\sdk\lib\dxguid.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib /nologo /subsystem:windows /machine:I386 /out:"../../../fteqw.exe" # ADD LINK32 comctl32.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib /nologo /subsystem:windows /pdb:none /map /machine:I386 /out:"../../fteglqw.exe" +# SUBTRACT LINK32 /debug !ELSEIF "$(CFG)" == "ftequake - Win32 MDebug" diff --git a/engine/gl/gl_alias.c b/engine/gl/gl_alias.c index 2fe83240b..eb0db9be1 100644 --- a/engine/gl/gl_alias.c +++ b/engine/gl/gl_alias.c @@ -591,7 +591,7 @@ static galiastexnum_t *GL_ChooseSkin(galiasinfo_t *inf, char *modelname, entity_ int tc, bc; - if (!gl_nocolors.value && !cls.q2server) + if (!gl_nocolors.value) { if (e->scoreboard) { @@ -633,17 +633,16 @@ static galiastexnum_t *GL_ChooseSkin(galiasinfo_t *inf, char *modelname, entity_ qbyte *original; int cc; galiascolourmapped_t *cm; + char hashname[512]; cc = (tc<<4)|bc; - - if (!strstr(modelname, "progs/player.mdl")) - skinname = modelname; - else + + if (e->scoreboard && e->scoreboard->skin && !gl_nocolors.value) { - if (e->scoreboard && e->scoreboard->skin && !gl_nocolors.value) - skinname = e->scoreboard->skin->name; - else - skinname = modelname; + sprintf(hashname, "%s$%s", modelname, e->scoreboard->skin->name); + skinname = hashname; } + else + skinname = modelname; if (!skincolourmapped.numbuckets) Hash_InitTable(&skincolourmapped, 256, BZ_Malloc(Hash_BytesForBuckets(256))); @@ -656,14 +655,21 @@ static galiastexnum_t *GL_ChooseSkin(galiasinfo_t *inf, char *modelname, entity_ } } - skins = (galiasskin_t*)((char *)inf + inf->ofsskins); - if (!skins->texnums) - return NULL; - if (e->skinnum >= 0 && e->skinnum < inf->numskins) - skins += e->skinnum; - texnums = (galiastexnum_t*)((char *)skins + skins->ofstexnums); - - + if (!inf->numskins) + { + skins = NULL; + texnums = NULL; + } + else + { + skins = (galiasskin_t*)((char *)inf + inf->ofsskins); + if (!skins->texnums) + return NULL; + if (e->skinnum >= 0 && e->skinnum < inf->numskins) + skins += e->skinnum; + texnums = (galiastexnum_t*)((char *)skins + skins->ofstexnums); + } + //colourmap isn't present yet. cm = BZ_Malloc(sizeof(*cm)); Q_strncpyz(cm->name, skinname, sizeof(cm->name)); @@ -672,8 +678,25 @@ static galiastexnum_t *GL_ChooseSkin(galiasinfo_t *inf, char *modelname, entity_ cm->skinnum = e->skinnum; cm->texnum.fullbright = 0; cm->texnum.base = 0; + + if (!texnums) + { //load just the skin + if (e->scoreboard && e->scoreboard->skin) + { + original = Skin_Cache8(e->scoreboard->skin); + if (!original) + return NULL; + inwidth = e->scoreboard->skin->width; + inheight = e->scoreboard->skin->height; + + cm->texnum.base = cm->texnum.fullbright = GL_LoadTexture(e->scoreboard->skin->name, inwidth, inheight, original, true, false); + return &cm->texnum; + } + return NULL; + } + cm->texnum.bump = texnums[cm->skinnum].bump; //can't colour bumpmapping - if (skinname!=modelname && e->scoreboard && e->scoreboard->skin) + if ((!texnums || skinname!=modelname) && e->scoreboard && e->scoreboard->skin) { original = Skin_Cache8(e->scoreboard->skin); inwidth = e->scoreboard->skin->width; diff --git a/engine/gl/gl_draw.c b/engine/gl/gl_draw.c index 0ea8be649..94d69b64a 100644 --- a/engine/gl/gl_draw.c +++ b/engine/gl/gl_draw.c @@ -3188,15 +3188,17 @@ void GL_Upload8 (qbyte *data, int width, int height, qboolean mipmap, qboolean } else { - if (s&3) - Sys_Error ("GL_Upload8: s&3"); - for (i=0 ; i=0 ; i-=4) { trans[i] = d_8to24rgbtable[data[i]]; trans[i+1] = d_8to24rgbtable[data[i+1]]; trans[i+2] = d_8to24rgbtable[data[i+2]]; trans[i+3] = d_8to24rgbtable[data[i+3]]; } + for (i=s&~3 ; ialphaed) + { + qglEnable(GL_BLEND); + GL_TexEnv(GL_MODULATE); + } + else + { + qglDisable(GL_BLEND); + GL_TexEnv(GL_REPLACE); + } + + + GL_MBind(GL_TEXTURE0_ARB, tex->gl_texturenum); + qglEnableClientState(GL_TEXTURE_COORD_ARRAY); + + GL_SelectTexture(GL_TEXTURE1_ARB); + GL_TexEnv(GL_MODULATE); + qglEnableClientState(GL_TEXTURE_COORD_ARRAY); + + vi = -1; + for (; s ; s=s->texturechain) + { + if (vi != s->lightmaptexturenum) + { + if (vi<0) + qglEnable(GL_TEXTURE_2D); + vi = s->lightmaptexturenum; + + if (vi>=0) + { + GL_Bind(lightmap_textures[vi] ); + if (lightmap[vi]->modified) + { + lightmap[vi]->modified = false; + theRect = &lightmap[vi]->rectchange; + qglTexSubImage2D(GL_TEXTURE_2D, 0, 0, theRect->t, + LMBLOCK_WIDTH, theRect->h, gl_lightmap_format, GL_UNSIGNED_BYTE, + lightmap[vi]->lightmaps+(theRect->t) *LMBLOCK_WIDTH*lightmap_bytes); + theRect->l = LMBLOCK_WIDTH; + theRect->t = LMBLOCK_HEIGHT; + theRect->h = 0; + theRect->w = 0; + } + } + else + qglDisable(GL_TEXTURE_2D); + } + + qglClientActiveTextureARB(GL_TEXTURE0_ARB); + qglTexCoordPointer(2, GL_FLOAT, VERTEXSIZE*sizeof(GL_FLOAT), s->polys[0].verts[0]+3); + qglClientActiveTextureARB(GL_TEXTURE1_ARB); + qglTexCoordPointer(2, GL_FLOAT, VERTEXSIZE*sizeof(GL_FLOAT), s->polys[0].verts[0]+5); + + qglVertexPointer(3, GL_FLOAT, VERTEXSIZE*sizeof(GL_FLOAT), s->polys[0].verts[0]); + + qglDrawElements(GL_TRIANGLES, (s->polys[0].numverts-2)*3, GL_UNSIGNED_INT, varray_i_polytotri); + } + + qglDisable(GL_TEXTURE_2D); + qglDisableClientState(GL_TEXTURE_COORD_ARRAY); + + GL_SelectTexture(GL_TEXTURE0_ARB); + qglDisableClientState(GL_TEXTURE_COORD_ARRAY); +} + static void PPL_BaseChain_Bump_2TMU(msurface_t *first, texture_t *tex) { int vi; @@ -1617,7 +1689,8 @@ static void PPL_BaseTextureChain(msurface_t *first) } else { - PPL_BaseChain_NoBump_2TMU(first, t); + PPL_BaseChain_NoBump_2TMU_NoMerge(first, t); +// PPL_BaseChain_NoBump_2TMU(first, t); } } } diff --git a/engine/gl/gl_shader.c b/engine/gl/gl_shader.c index 167643150..cc87e02a3 100644 --- a/engine/gl/gl_shader.c +++ b/engine/gl/gl_shader.c @@ -1686,14 +1686,204 @@ void Shader_RunCinematic (void) } } -int R_LoadShader ( char *name, int type ) +void Shader_DefaultBSP(char *shortname, shader_t *s) +{ + shaderpass_t *pass; + pass = &s->passes[0]; + pass->flags = SHADER_PASS_LIGHTMAP | SHADER_PASS_DEPTHWRITE | SHADER_PASS_NOCOLORARRAY; + pass->tcgen = TC_GEN_LIGHTMAP; + pass->anim_frames[0] = 0; + pass->depthfunc = GL_LEQUAL; + pass->blendmode = GL_REPLACE; + pass->alphagen = ALPHA_GEN_IDENTITY; + pass->rgbgen = RGB_GEN_IDENTITY; + pass->numMergedPasses = 2; + + if ( qglMTexCoord2fSGIS ) + { + pass->numMergedPasses = 2; + pass->flush = R_RenderMeshMultitextured; + } + else + { + pass->numMergedPasses = 1; + pass->flush = R_RenderMeshGeneric; + } + + pass = &s->passes[1]; + pass->flags = SHADER_PASS_BLEND | SHADER_PASS_NOCOLORARRAY; + pass->tcgen = TC_GEN_BASE; + pass->anim_frames[0] = Mod_LoadHiResTexture(shortname, true, false, true);//GL_FindImage (shortname, 0); + pass->blendsrc = GL_ZERO; + pass->blenddst = GL_SRC_COLOR; + pass->blendmode = GL_MODULATE; + pass->depthfunc = GL_LEQUAL; + pass->rgbgen = RGB_GEN_IDENTITY; + pass->alphagen = ALPHA_GEN_IDENTITY; + + pass->numMergedPasses = 1; + pass->flush = R_RenderMeshGeneric; + + if ( !pass->anim_frames[0] ) { + Con_DPrintf ( S_COLOR_YELLOW "Shader %s has a stage with no image: %s.\n", s->name, shortname ); + pass->anim_frames[0] = 0;//fizme:r_notexture; + } + + s->numpasses = 2; + s->numdeforms = 0; + s->flags = SHADER_DEPTHWRITE|SHADER_CULL_FRONT; + s->features = MF_STCOORDS|MF_LMCOORDS|MF_TRNORMALS; + s->sort = SHADER_SORT_OPAQUE; + s->registration_sequence = 1;//fizme: registration_sequence; +} + +void Shader_DefaultBSPVertex(char *shortname, shader_t *s) +{ + shaderpass_t *pass; + pass = &s->passes[0]; + pass->tcgen = TC_GEN_BASE; + pass->anim_frames[0] = Mod_LoadHiResTexture(shortname, true, false, true);//GL_FindImage (shortname, 0); + pass->depthfunc = GL_LEQUAL; + pass->flags = SHADER_PASS_DEPTHWRITE; + pass->rgbgen = RGB_GEN_VERTEX; + pass->alphagen = ALPHA_GEN_IDENTITY; + pass->blendmode = GL_MODULATE; + pass->numMergedPasses = 1; + pass->flush = R_RenderMeshGeneric; + + if ( !pass->anim_frames[0] ) { + Con_DPrintf ( S_COLOR_YELLOW "Shader %s has a stage with no image: %s.\n", s->name, shortname ); + pass->anim_frames[0] = 0;//fizme:r_notexture; + } + + s->numpasses = 1; + s->numdeforms = 0; + s->flags = SHADER_DEPTHWRITE|SHADER_CULL_FRONT; + s->features = MF_STCOORDS|MF_COLORS|MF_TRNORMALS; + s->sort = SHADER_SORT_OPAQUE; + s->registration_sequence = 1;//fizme: registration_sequence; +} +void Shader_DefaultBSPFlare(char *shortname, shader_t *s) +{ + shaderpass_t *pass; + pass = &s->passes[0]; + pass->flags = SHADER_PASS_BLEND | SHADER_PASS_NOCOLORARRAY; + pass->blendsrc = GL_ONE; + pass->blenddst = GL_ONE; + pass->blendmode = GL_MODULATE; + pass->anim_frames[0] = Mod_LoadHiResTexture(shortname, true, true, true);//GL_FindImage (shortname, 0); + pass->depthfunc = GL_LEQUAL; + pass->rgbgen = RGB_GEN_VERTEX; + pass->alphagen = ALPHA_GEN_IDENTITY; + pass->numtcmods = 0; + pass->tcgen = TC_GEN_BASE; + pass->numMergedPasses = 1; + pass->flush = R_RenderMeshGeneric; + + if ( !pass->anim_frames[0] ) { + Con_DPrintf ( S_COLOR_YELLOW "Shader %s has a stage with no image: %s.\n", s->name, shortname ); + pass->anim_frames[0] = 0;//fizme:r_notexture; + } + + s->numpasses = 1; + s->numdeforms = 0; + s->flags = SHADER_FLARE; + s->features = MF_STCOORDS|MF_COLORS; + s->sort = SHADER_SORT_ADDITIVE; + s->registration_sequence = 1;//fizme: registration_sequence; +} +void Shader_DefaultSkin(char *shortname, shader_t *s) +{ + shaderpass_t *pass; + pass = &s->passes[0]; + pass->flags = SHADER_PASS_DEPTHWRITE; + pass->anim_frames[0] = Mod_LoadHiResTexture(shortname, true, true, true);//GL_FindImage (shortname, 0); + pass->depthfunc = GL_LEQUAL; + pass->rgbgen = RGB_GEN_LIGHTING_DIFFUSE; + pass->numtcmods = 0; + pass->tcgen = TC_GEN_BASE; + pass->blendmode = GL_MODULATE; + pass->numMergedPasses = 1; + pass->flush = R_RenderMeshGeneric; + + if ( !pass->anim_frames[0] ) { + Con_DPrintf ( S_COLOR_YELLOW "Shader %s has a stage with no image: %s.\n", s->name, shortname ); + pass->anim_frames[0] = 0;//fizme:r_notexture; + } + + s->numpasses = 1; + s->numdeforms = 0; + s->flags = SHADER_DEPTHWRITE|SHADER_CULL_FRONT; + s->features = MF_STCOORDS|MF_NORMALS; + s->sort = SHADER_SORT_OPAQUE; + s->registration_sequence = 1;//fizme: registration_sequence; +} +void Shader_DefaultSkinShell(char *shortname, shader_t *s) +{ + shaderpass_t *pass; + pass = &s->passes[0]; + pass->flags = SHADER_PASS_DEPTHWRITE | SHADER_PASS_BLEND; + pass->anim_frames[0] = Mod_LoadHiResTexture(shortname, true, true, true);//GL_FindImage (shortname, 0); + pass->depthfunc = GL_LEQUAL; + pass->rgbgen = RGB_GEN_ENTITY; + pass->alphagen = ALPHA_GEN_ENTITY; + pass->numtcmods = 0; + pass->tcgen = TC_GEN_BASE; + pass->blendsrc = GL_SRC_ALPHA; + pass->blenddst = GL_ONE_MINUS_SRC_ALPHA; + pass->blendmode = GL_MODULATE; + pass->numMergedPasses = 1; + pass->flush = R_RenderMeshGeneric; + + if ( !pass->anim_frames[0] ) { + Con_DPrintf ( S_COLOR_YELLOW "Shader %s has a stage with no image: %s.\n", s->name, shortname ); + pass->anim_frames[0] = 0;//fizme:r_notexture; + } + + s->numpasses = 1; + s->numdeforms = 0; + s->flags = SHADER_DEPTHWRITE|SHADER_CULL_FRONT; + s->features = MF_STCOORDS|MF_NORMALS; + s->sort = SHADER_SORT_OPAQUE; + s->registration_sequence = 1;//fizme: registration_sequence; +} +void Shader_Default2D(char *shortname, shader_t *s) +{ + shaderpass_t *pass; + pass = &s->passes[0]; + pass->flags = SHADER_PASS_BLEND | SHADER_PASS_NOCOLORARRAY; + pass->blendsrc = GL_SRC_ALPHA; + pass->blenddst = GL_ONE_MINUS_SRC_ALPHA; + pass->blendmode = GL_MODULATE; + pass->anim_frames[0] = Mod_LoadHiResTexture(shortname, false, true, true);//GL_FindImage (shortname, IT_NOPICMIP|IT_NOMIPMAP); + pass->depthfunc = GL_LEQUAL; + pass->rgbgen = RGB_GEN_VERTEX; + pass->alphagen = ALPHA_GEN_VERTEX; + pass->numtcmods = 0; + pass->tcgen = TC_GEN_BASE; + pass->numMergedPasses = 1; + pass->flush = R_RenderMeshGeneric; + + if ( !pass->anim_frames[0] ) { + Con_DPrintf ( S_COLOR_YELLOW "Shader %s has a stage with no image: %s.\n", s->name, shortname ); + pass->anim_frames[0] = 0;//fizme:r_notexture; + } + + s->numpasses = 1; + s->numdeforms = 0; + s->flags = SHADER_NOPICMIP|SHADER_NOMIPMAPS|SHADER_BLEND; + s->features = MF_STCOORDS|MF_COLORS; + s->sort = SHADER_SORT_ADDITIVE; + s->registration_sequence = 1;//fizme: registration_sequence; +} + +int R_LoadShader ( char *name, void(*defaultgen)(char *name, shader_t*)) { int i, f = -1; unsigned int offset, length = 0; char shortname[MAX_QPATH], path[MAX_QPATH]; char *buf = NULL, *ts = NULL; shader_t *s; - shaderpass_t *pass; COM_StripExtension ( name, shortname ); @@ -1768,166 +1958,10 @@ int R_LoadShader ( char *name, int type ) } else // make a default shader { - switch (type) - { - case SHADER_BSP: - pass = &s->passes[0]; - pass->flags = SHADER_PASS_LIGHTMAP | SHADER_PASS_DEPTHWRITE | SHADER_PASS_NOCOLORARRAY; - pass->tcgen = TC_GEN_LIGHTMAP; - pass->anim_frames[0] = 0; - pass->depthfunc = GL_LEQUAL; - pass->blendmode = GL_REPLACE; - pass->alphagen = ALPHA_GEN_IDENTITY; - pass->rgbgen = RGB_GEN_IDENTITY; - pass->numMergedPasses = 2; - - if ( qglMTexCoord2fSGIS ) - { - pass->numMergedPasses = 2; - pass->flush = R_RenderMeshMultitextured; - } - else - { - pass->numMergedPasses = 1; - pass->flush = R_RenderMeshGeneric; - } - - pass = &s->passes[1]; - pass->flags = SHADER_PASS_BLEND | SHADER_PASS_NOCOLORARRAY; - pass->tcgen = TC_GEN_BASE; - pass->anim_frames[0] = Mod_LoadHiResTexture(shortname, true, false, true);//GL_FindImage (shortname, 0); - pass->blendsrc = GL_ZERO; - pass->blenddst = GL_SRC_COLOR; - pass->blendmode = GL_MODULATE; - pass->depthfunc = GL_LEQUAL; - pass->rgbgen = RGB_GEN_IDENTITY; - pass->alphagen = ALPHA_GEN_IDENTITY; - - pass->numMergedPasses = 1; - pass->flush = R_RenderMeshGeneric; - - if ( !pass->anim_frames[0] ) { - Con_DPrintf ( S_COLOR_YELLOW "Shader %s has a stage with no image: %s.\n", s->name, shortname ); - pass->anim_frames[0] = 0;//fizme:r_notexture; - } - - s->numpasses = 2; - s->numdeforms = 0; - s->flags = SHADER_DEPTHWRITE|SHADER_CULL_FRONT; - s->features = MF_STCOORDS|MF_LMCOORDS|MF_TRNORMALS; - s->sort = SHADER_SORT_OPAQUE; - s->registration_sequence = 1;//fizme: registration_sequence; - break; - - case SHADER_BSP_VERTEX: - pass = &s->passes[0]; - pass->tcgen = TC_GEN_BASE; - pass->anim_frames[0] = Mod_LoadHiResTexture(shortname, true, false, true);//GL_FindImage (shortname, 0); - pass->depthfunc = GL_LEQUAL; - pass->flags = SHADER_PASS_DEPTHWRITE; - pass->rgbgen = RGB_GEN_VERTEX; - pass->alphagen = ALPHA_GEN_IDENTITY; - pass->blendmode = GL_MODULATE; - pass->numMergedPasses = 1; - pass->flush = R_RenderMeshGeneric; - - if ( !pass->anim_frames[0] ) { - Con_DPrintf ( S_COLOR_YELLOW "Shader %s has a stage with no image: %s.\n", s->name, shortname ); - pass->anim_frames[0] = 0;//fizme:r_notexture; - } - - s->numpasses = 1; - s->numdeforms = 0; - s->flags = SHADER_DEPTHWRITE|SHADER_CULL_FRONT; - s->features = MF_STCOORDS|MF_COLORS|MF_TRNORMALS; - s->sort = SHADER_SORT_OPAQUE; - s->registration_sequence = 1;//fizme: registration_sequence; - break; - - case SHADER_BSP_FLARE: - pass = &s->passes[0]; - pass->flags = SHADER_PASS_BLEND | SHADER_PASS_NOCOLORARRAY; - pass->blendsrc = GL_ONE; - pass->blenddst = GL_ONE; - pass->blendmode = GL_MODULATE; - pass->anim_frames[0] = Mod_LoadHiResTexture(shortname, true, true, true);//GL_FindImage (shortname, 0); - pass->depthfunc = GL_LEQUAL; - pass->rgbgen = RGB_GEN_VERTEX; - pass->alphagen = ALPHA_GEN_IDENTITY; - pass->numtcmods = 0; - pass->tcgen = TC_GEN_BASE; - pass->numMergedPasses = 1; - pass->flush = R_RenderMeshGeneric; - - if ( !pass->anim_frames[0] ) { - Con_DPrintf ( S_COLOR_YELLOW "Shader %s has a stage with no image: %s.\n", s->name, shortname ); - pass->anim_frames[0] = 0;//fizme:r_notexture; - } - - s->numpasses = 1; - s->numdeforms = 0; - s->flags = SHADER_FLARE; - s->features = MF_STCOORDS|MF_COLORS; - s->sort = SHADER_SORT_ADDITIVE; - s->registration_sequence = 1;//fizme: registration_sequence; - break; - - case SHADER_MD3: - pass = &s->passes[0]; - pass->flags = SHADER_PASS_DEPTHWRITE; - pass->anim_frames[0] = Mod_LoadHiResTexture(shortname, true, true, true);//GL_FindImage (shortname, 0); - pass->depthfunc = GL_LEQUAL; - pass->rgbgen = RGB_GEN_LIGHTING_DIFFUSE; - pass->numtcmods = 0; - pass->tcgen = TC_GEN_BASE; - pass->blendmode = GL_MODULATE; - pass->numMergedPasses = 1; - pass->flush = R_RenderMeshGeneric; - - if ( !pass->anim_frames[0] ) { - Con_DPrintf ( S_COLOR_YELLOW "Shader %s has a stage with no image: %s.\n", s->name, shortname ); - pass->anim_frames[0] = 0;//fizme:r_notexture; - } - - s->numpasses = 1; - s->numdeforms = 0; - s->flags = SHADER_DEPTHWRITE|SHADER_CULL_FRONT; - s->features = MF_STCOORDS|MF_NORMALS; - s->sort = SHADER_SORT_OPAQUE; - s->registration_sequence = 1;//fizme: registration_sequence; - break; - - case SHADER_2D: - pass = &s->passes[0]; - pass->flags = SHADER_PASS_BLEND | SHADER_PASS_NOCOLORARRAY; - pass->blendsrc = GL_SRC_ALPHA; - pass->blenddst = GL_ONE_MINUS_SRC_ALPHA; - pass->blendmode = GL_MODULATE; - pass->anim_frames[0] = Mod_LoadHiResTexture(shortname, false, true, true);//GL_FindImage (shortname, IT_NOPICMIP|IT_NOMIPMAP); - pass->depthfunc = GL_LEQUAL; - pass->rgbgen = RGB_GEN_VERTEX; - pass->alphagen = ALPHA_GEN_VERTEX; - pass->numtcmods = 0; - pass->tcgen = TC_GEN_BASE; - pass->numMergedPasses = 1; - pass->flush = R_RenderMeshGeneric; - - if ( !pass->anim_frames[0] ) { - Con_DPrintf ( S_COLOR_YELLOW "Shader %s has a stage with no image: %s.\n", s->name, shortname ); - pass->anim_frames[0] = 0;//fizme:r_notexture; - } - - s->numpasses = 1; - s->numdeforms = 0; - s->flags = SHADER_NOPICMIP|SHADER_NOMIPMAPS|SHADER_BLEND; - s->features = MF_STCOORDS|MF_COLORS; - s->sort = SHADER_SORT_ADDITIVE; - s->registration_sequence = 1;//fizme: registration_sequence; - break; - - default: - return -1; - } + if (defaultgen) + defaultgen(shortname, s); + else + return -1; } return f; @@ -1935,27 +1969,31 @@ int R_LoadShader ( char *name, int type ) shader_t *R_RegisterPic (char *name) { - return &r_shaders[R_LoadShader (name, SHADER_2D)]; + return &r_shaders[R_LoadShader (name, Shader_Default2D)]; } shader_t *R_RegisterShader (char *name) { - return &r_shaders[R_LoadShader (name, SHADER_BSP)]; + return &r_shaders[R_LoadShader (name, Shader_DefaultBSP)]; } shader_t *R_RegisterShader_Vertex (char *name) { - return &r_shaders[R_LoadShader (name, SHADER_BSP_VERTEX)]; + return &r_shaders[R_LoadShader (name, Shader_DefaultBSPVertex)]; } shader_t *R_RegisterShader_Flare (char *name) { - return &r_shaders[R_LoadShader (name, SHADER_BSP_FLARE)]; + return &r_shaders[R_LoadShader (name, Shader_DefaultBSPFlare)]; } shader_t *R_RegisterSkin (char *name) { - return &r_shaders[R_LoadShader (name, SHADER_MD3)]; + return &r_shaders[R_LoadShader (name, Shader_DefaultSkin)]; +} +shader_t *R_RegisterCustom (char *name, void(*defaultgen)(char *name, shader_t*)) +{ + return &r_shaders[R_LoadShader (name, defaultgen)]; } #endif diff --git a/engine/gl/shader.h b/engine/gl/shader.h index 8d5dd769c..bc67c875c 100644 --- a/engine/gl/shader.h +++ b/engine/gl/shader.h @@ -230,6 +230,9 @@ shader_t *R_RegisterShader (char *name); shader_t *R_RegisterShader_Vertex (char *name); shader_t *R_RegisterShader_Flare (char *name); shader_t *R_RegisterSkin (char *name); +shader_t *R_RegisterCustom (char *name, void(*defaultgen)(char *name, shader_t*)); + +void Shader_DefaultSkinShell(char *shortname, shader_t *s); void R_BackendInit (void); diff --git a/engine/qclib/qcc.h b/engine/qclib/qcc.h index 2a3bf0a56..4bdf61824 100644 --- a/engine/qclib/qcc.h +++ b/engine/qclib/qcc.h @@ -437,26 +437,37 @@ extern token_type_t pr_token_type; extern QCC_type_t *pr_immediate_type; extern QCC_eval_t pr_immediate; -extern pbool keyword_var; -extern pbool keyword_thinktime; -extern pbool keyword_switch; -extern pbool keyword_for; +extern pbool keyword_asm; +extern pbool keyword_break; extern pbool keyword_case; +extern pbool keyword_class; +extern pbool keyword_const; +extern pbool keyword_continue; extern pbool keyword_default; extern pbool keyword_do; -extern pbool keyword_asm; +extern pbool keyword_entity; +extern pbool keyword_float; +extern pbool keyword_for; extern pbool keyword_goto; -extern pbool keyword_break; -extern pbool keyword_continue; +extern pbool keyword_int; +extern pbool keyword_integer; extern pbool keyword_state; extern pbool keyword_string; -extern pbool keyword_float; -extern pbool keyword_entity; +extern pbool keyword_struct; +extern pbool keyword_switch; +extern pbool keyword_thinktime; +extern pbool keyword_var; extern pbool keyword_vector; -extern pbool keyword_integer; -extern pbool keyword_int; -extern pbool keyword_const; -extern pbool keyword_class; +extern pbool keyword_union; +extern pbool keyword_enum; //kinda like in c, but typedef not supported. +extern pbool keyword_enumflags; //like enum, but doubles instead of adds 1. +extern pbool keyword_typedef; //fixme +extern pbool keyword_extern; //function is external, don't error or warn if the body was not found +extern pbool keyword_shared; //mark global to be copied over when progs changes (part of FTE_MULTIPROGS) +extern pbool keyword_noref; //nowhere else references this, don't strip it. +extern pbool keyword_nosave; //don't write the def to the output. +extern pbool keyword_union; //you surly know what a union is! + extern pbool keywords_coexist; extern pbool output_parms; @@ -527,9 +538,10 @@ CompilerConstant_t *QCC_PR_DefineName(char *name); void QCC_RemapOffsets(unsigned int firststatement, unsigned int laststatement, unsigned int min, unsigned int max, unsigned int newmin); #ifndef COMMONINLINES -pbool QCC_PR_Check (char *string); -pbool QCC_PR_CheckInsens (char *string); +pbool QCC_PR_CheckToken (char *string); +pbool QCC_PR_CheckName (char *string); void QCC_PR_Expect (char *string); +pbool QCC_PR_CheckKeyword(int keywordenabled, char *string); #endif void VARGS QCC_PR_ParseError (int errortype, char *error, ...); void VARGS QCC_PR_ParseWarning (int warningtype, char *error, ...); @@ -587,6 +599,7 @@ enum { WARN_EXTENSION_USED, //extension that frikqcc also understands WARN_IFSTRING_USED, WARN_LAXCAST, //some errors become this with a compiler flag + WARN_UNDESIRABLECONVENTION, ERR_PARSEERRORS, //caused by qcc_pr_parseerror being called. @@ -847,9 +860,9 @@ extern qcc_cachedsourcefile_t *qcc_sourcefile; #ifdef COMMONINLINES -bool inline QCC_PR_Check (char *string) +bool inline QCC_PR_CheckToken (char *string) { - if (strcmp (string, pr_token)) + if (STRCMP (string, pr_token)) return false; QCC_PR_Lex (); diff --git a/engine/qclib/qcc_pr_comp.c b/engine/qclib/qcc_pr_comp.c index aefa100df..5cbcb6e21 100644 --- a/engine/qclib/qcc_pr_comp.c +++ b/engine/qclib/qcc_pr_comp.c @@ -12,26 +12,56 @@ extern char *compilingfile; int conditional; -pbool keyword_var; -pbool keyword_thinktime; -pbool keyword_switch; -pbool keyword_for; -pbool keyword_case; -pbool keyword_default; -pbool keyword_do; +//standard qcc keywords +#define keyword_do 1 +#define keyword_return 1 +#define keyword_if 1 +#define keyword_else 1 +#define keyword_local 1 +#define keyword_while 1 + +//extended keywords. pbool keyword_asm; -pbool keyword_goto; pbool keyword_break; -pbool keyword_continue; -pbool keyword_state; -pbool keyword_string; -pbool keyword_float; -pbool keyword_entity; -pbool keyword_vector; -pbool keyword_integer; -pbool keyword_int; -pbool keyword_const; +pbool keyword_case; pbool keyword_class; +pbool keyword_const; //fixme +pbool keyword_continue; +pbool keyword_default; +pbool keyword_entity; //for skipping the local +pbool keyword_float; //for skipping the local +pbool keyword_for; +pbool keyword_goto; +pbool keyword_int; //for skipping the local +pbool keyword_integer; //for skipping the local +pbool keyword_state; +pbool keyword_string; //for skipping the local +pbool keyword_struct; +pbool keyword_switch; +pbool keyword_thinktime; +pbool keyword_var; //allow it to be initialised and set around the place. +pbool keyword_vector; //for skipping the local + + +pbool keyword_enum; //kinda like in c, but typedef not supported. +pbool keyword_enumflags; //like enum, but doubles instead of adds 1. +pbool keyword_typedef; //fixme +#define keyword_codesys flag_acc //reacc needs this (forces the resultant crc) +#define keyword_function flag_acc //reacc needs this (reacc has this on all functions, wierd eh?) +#define keyword_objdata flag_acc //reacc needs this (following defs are fields rather than globals, use var to disable) +#define keyword_object flag_acc //reacc needs this (an entity) +#define keyword_pfunc flag_acc //reacc needs this (pointer to function) +#define keyword_system flag_acc //reacc needs this (potatos) +#define keyword_real flag_acc //reacc needs this (a float) +#define keyword_exit flag_acc //emits an OP_DONE opcode. +#define keyword_external flag_acc //reacc needs this (a builtin) +pbool keyword_extern; //function is external, don't error or warn if the body was not found +pbool keyword_shared; //mark global to be copied over when progs changes (part of FTE_MULTIPROGS) +pbool keyword_noref; //nowhere else references this, don't strip it. +pbool keyword_nosave; //don't write the def to the output. +pbool keyword_union; //you surly know what a union is! + +#define keyword_not 1 //hexenc support needs this, and fteqcc can optimise without it, but it adds an extra token after the if, so it can cause no namespace conflicts pbool keywords_coexist; //don't disable a keyword simply because a var was made with the same name. pbool output_parms; //emit some PARMX fields. confuses decompilers. @@ -2080,12 +2110,12 @@ QCC_def_t *QCC_PR_ParseFunctionCall (QCC_def_t *func) //warning, the func could if (!strcmp(func->name, "random")) { func->references++; - if (!QCC_PR_Check(")")) + if (!QCC_PR_CheckToken(")")) { e = QCC_PR_Expression (TOP_PRIORITY); if (e->type->type != ev_float) QCC_PR_ParseErrorPrintDef (ERR_TYPEMISMATCHPARM, func, "type mismatch on parm %i", 1); - if (!QCC_PR_Check(")")) + if (!QCC_PR_CheckToken(")")) { QCC_PR_Expect(","); d = QCC_PR_Expression (TOP_PRIORITY); @@ -2201,12 +2231,12 @@ QCC_def_t *QCC_PR_ParseFunctionCall (QCC_def_t *func) //warning, the func could if (!strcmp(func->name, "randomv")) { func->references++; - if (!QCC_PR_Check(")")) + if (!QCC_PR_CheckToken(")")) { e = QCC_PR_Expression (TOP_PRIORITY); if (e->type->type != ev_vector) QCC_PR_ParseErrorPrintDef (ERR_TYPEMISMATCHPARM, func, "type mismatch on parm %i", 1); - if (!QCC_PR_Check(")")) + if (!QCC_PR_CheckToken(")")) { QCC_PR_Expect(","); d = QCC_PR_Expression (TOP_PRIORITY); @@ -2382,7 +2412,7 @@ QCC_def_t *QCC_PR_ParseFunctionCall (QCC_def_t *func) //warning, the func could else if (!strcmp(func->name, "spawn")) { QCC_type_t *rettype; - if (QCC_PR_Check(")")) + if (QCC_PR_CheckToken(")")) { rettype = type_entity; } @@ -2505,7 +2535,7 @@ QCC_def_t *QCC_PR_ParseFunctionCall (QCC_def_t *func) //warning, the func could } else { - if (!QCC_PR_Check(")")) + if (!QCC_PR_CheckToken(")")) { p = t->param; do @@ -2623,7 +2653,7 @@ QCC_def_t *QCC_PR_ParseFunctionCall (QCC_def_t *func) //warning, the func could QCC_PR_Statement (&pr_opcodes[OP_STORE_F], e, d, (QCC_dstatement_t **)0xffffffff); */ arg++; - } while (QCC_PR_Check (",")); + } while (QCC_PR_CheckToken (",")); if (t->num_parms != -1 && arg < np) QCC_PR_ParseWarning (WARN_TOOFEWPARAMS, "too few parameters on call to %s", func->name); @@ -3154,7 +3184,7 @@ QCC_def_t *QCC_PR_ParseValue (QCC_type_t *assumeclass) if (pr_token_type == tt_immediate) return QCC_PR_ParseImmediate (); - if (QCC_PR_Check("[")) //reacc support + if (QCC_PR_CheckToken("[")) //reacc support { //looks like a funky vector. :) vec3_t v; pr_immediate_type = type_vector; @@ -3231,7 +3261,7 @@ reloop: //FIXME: Make this work with double arrays/2nd level structures. //Should they just jump back to here? - if (QCC_PR_Check("[")) + if (QCC_PR_CheckToken("[")) { QCC_type_t *newtype; if (ao) @@ -3346,7 +3376,7 @@ reloop: { if (qcc_targetformat == QCF_HEXEN2) { //hexen2 style retrieval, mixed with q1 style assignments... - if (QCC_PR_Check("=")) //(hideous concept) + if (QCC_PR_CheckToken("=")) //(hideous concept) { QCC_dstatement_t *st; QCC_def_t *funcretr; @@ -3420,7 +3450,7 @@ reloop: def_parms[0].type = type_float; QCC_FreeTemp(QCC_PR_Statement (&pr_opcodes[OP_STORE_F], ao, &def_parms[0], NULL)); - if (QCC_PR_Check("=")) + if (QCC_PR_CheckToken("=")) { funcretr = QCC_PR_GetDef(type_function, qcva("ArraySet*%s", d->name), NULL, true, 1); nd = QCC_PR_Expression(TOP_PRIORITY); @@ -3531,11 +3561,11 @@ reloop: { int j; QCC_type_t *type; - if (QCC_PR_Check(".") || QCC_PR_Check("->")) + if (QCC_PR_CheckToken(".") || QCC_PR_CheckToken("->")) { for (i = d->type->num_parms, type = d->type+1; i; i--, type++) { - if (QCC_PR_Check(type->name)) + if (QCC_PR_CheckName(type->name)) { //give result if (ao) @@ -3605,11 +3635,11 @@ reloop: { int j; QCC_type_t *type; - if (QCC_PR_Check(".") || QCC_PR_Check("->")) + if (QCC_PR_CheckToken(".") || QCC_PR_CheckToken("->")) { for (i = d->type->num_parms, type = d->type+1; i; i--, type++) { - if (QCC_PR_Check(type->name)) + if (QCC_PR_CheckName(type->name)) { //give result if (ao) @@ -3694,10 +3724,10 @@ reloop: if (d->type->parentclass||d->type->type == ev_entity) //class { - if (QCC_PR_Check(".") || QCC_PR_Check("->")) + if (QCC_PR_CheckToken(".") || QCC_PR_CheckToken("->")) { QCC_def_t *field; - if (QCC_PR_Check("(")) + if (QCC_PR_CheckToken("(")) { field = QCC_PR_Expression(TOP_PRIORITY); QCC_PR_Expect(")"); @@ -3774,7 +3804,7 @@ QCC_def_t *QCC_PR_Term (void) etype_t t; if (pr_token_type == tt_punct) //a little extra speed... { - if (QCC_PR_Check("++")) //supposedly. I'm unsure weather it works properly. + if (QCC_PR_CheckToken("++")) { qcc_usefulstatement=true; e = QCC_PR_Term (); @@ -3796,7 +3826,7 @@ QCC_def_t *QCC_PR_Term (void) } return e; } - else if (QCC_PR_Check("--")) + else if (QCC_PR_CheckToken("--")) { qcc_usefulstatement=true; e = QCC_PR_Term (); @@ -3819,7 +3849,7 @@ QCC_def_t *QCC_PR_Term (void) return e; } - if (QCC_PR_Check ("!")) + if (QCC_PR_CheckToken ("!")) { e = QCC_PR_Expression (NOT_PRIORITY); t = e->type->type; @@ -3845,7 +3875,7 @@ QCC_def_t *QCC_PR_Term (void) return e2; } - else if (QCC_PR_Check ("&")) + else if (QCC_PR_CheckToken ("&")) { int st = numstatements; e = QCC_PR_Expression (NOT_PRIORITY); @@ -3876,7 +3906,7 @@ QCC_def_t *QCC_PR_Term (void) e2->type = QCC_PR_PointerType(e->type); return e2; } - else if (QCC_PR_Check ("*")) + else if (QCC_PR_CheckToken ("*")) { e = QCC_PR_Expression (NOT_PRIORITY); t = e->type->type; @@ -3920,7 +3950,7 @@ QCC_def_t *QCC_PR_Term (void) e2->type = e->type->aux_type; return e2; } - else if (QCC_PR_Check ("-")) + else if (QCC_PR_CheckToken ("-")) { e = QCC_PR_Expression (NOT_PRIORITY); @@ -3939,7 +3969,7 @@ QCC_def_t *QCC_PR_Term (void) } return e2; } - else if (QCC_PR_Check ("+")) + else if (QCC_PR_CheckToken ("+")) { e = QCC_PR_Expression (NOT_PRIORITY); @@ -3959,9 +3989,9 @@ QCC_def_t *QCC_PR_Term (void) return e2; } - if (QCC_PR_Check ("(")) + if (QCC_PR_CheckToken ("(")) { - if (keyword_float && QCC_PR_Check("float")) //check for type casts + if (keyword_float && QCC_PR_CheckToken("float")) //check for type casts { QCC_PR_Expect (")"); e = QCC_PR_Term(); @@ -3984,7 +4014,7 @@ QCC_def_t *QCC_PR_Term (void) e2->temp = e->temp; return e2; } - else if (keyword_class && QCC_PR_Check("class")) + else if (QCC_PR_CheckKeyword(keyword_class, "class")) { QCC_type_t *classtype = QCC_TypeForName(QCC_PR_ParseName()); if (!classtype) @@ -4000,7 +4030,7 @@ QCC_def_t *QCC_PR_Term (void) e2->temp = e->temp; return e2; } - else if (keyword_integer && QCC_PR_Check("integer")) //check for type casts + else if (QCC_PR_CheckKeyword(keyword_integer, "integer")) //check for type casts { QCC_PR_Expect (")"); e = QCC_PR_Term(); @@ -4011,7 +4041,7 @@ QCC_def_t *QCC_PR_Term (void) else QCC_PR_ParseError (ERR_BADTYPECAST, "invalid typecast"); } - else if (keyword_int && QCC_PR_Check("int")) //check for type casts + else if (QCC_PR_CheckKeyword(keyword_int, "int")) //check for type casts { QCC_PR_Expect (")"); e = QCC_PR_Term(); @@ -4091,7 +4121,7 @@ QCC_def_t *QCC_PR_Expression (int priority) while (1) { - if (priority == 1 && QCC_PR_Check ("(") ) + if (priority == 1 && QCC_PR_CheckToken ("(") ) { qcc_usefulstatement=true; return QCC_PR_ParseFunctionCall (e); @@ -4121,7 +4151,7 @@ QCC_def_t *QCC_PR_Expression (int priority) { // if (op->priority != priority) // continue; - if (!QCC_PR_Check (op->name)) + if (!QCC_PR_CheckToken (op->name)) continue; st = NULL; if ( op->associative!=ASSOC_LEFT ) @@ -4477,10 +4507,10 @@ void QCC_PR_ParseStatement (void) QCC_def_t *e, *e2; QCC_dstatement_t *patch1, *patch2, *patch3; - if (QCC_PR_Check ("{")) + if (QCC_PR_CheckToken ("{")) { e = pr.localvars; - while (!QCC_PR_Check("}")) + while (!QCC_PR_CheckToken("}")) QCC_PR_ParseStatement (); if (pr_subscopedlocals) @@ -4493,7 +4523,7 @@ void QCC_PR_ParseStatement (void) return; } - if (QCC_PR_Check("return")) + if (QCC_PR_CheckKeyword(keyword_return, "return")) { /*if (pr_classtype) { @@ -4502,7 +4532,7 @@ void QCC_PR_ParseStatement (void) QCC_FreeTemp(QCC_PR_Statement(&pr_opcodes[OP_STORE_ENT], e, QCC_PR_DummyDef(pr_classtype, "self", pr_scope, 1, e2->ofs, false), NULL)); }*/ - if (QCC_PR_Check (";")) + if (QCC_PR_CheckToken (";")) { if (pr_scope->type->aux_type->type != ev_void) QCC_PR_ParseWarning(WARN_MISSINGRETURNVALUE, "\'%s\' should return %s", pr_scope->name, pr_scope->type->aux_type->name); @@ -4519,14 +4549,14 @@ void QCC_PR_ParseStatement (void) QCC_FreeTemp(QCC_PR_Statement (&pr_opcodes[OP_RETURN], e, 0, NULL)); return; } - if (QCC_PR_Check("exit")) + if (QCC_PR_CheckKeyword(keyword_exit, "exit")) { QCC_FreeTemp(QCC_PR_Statement (&pr_opcodes[OP_DONE], 0, 0, NULL)); QCC_PR_Expect (";"); return; } - if (QCC_PR_Check("while")) + if (QCC_PR_CheckKeyword(keyword_while, "while")) { continues = num_continues; breaks = num_breaks; @@ -4598,7 +4628,7 @@ void QCC_PR_ParseStatement (void) } return; } - if (keyword_for && QCC_PR_Check("for")) + if (QCC_PR_CheckKeyword(keyword_for, "for")) { int old_numstatements; int numtemp, i; @@ -4610,21 +4640,21 @@ void QCC_PR_ParseStatement (void) breaks = num_breaks; QCC_PR_Expect("("); - if (!QCC_PR_Check(";")) + if (!QCC_PR_CheckToken(";")) { do { QCC_FreeTemp(QCC_PR_Expression(TOP_PRIORITY)); - } while (QCC_PR_Check(",")); + } while (QCC_PR_CheckToken(",")); QCC_PR_Expect(";"); } patch2 = &statements[numstatements]; - if (!QCC_PR_Check(";")) + if (!QCC_PR_CheckToken(";")) { conditional = 1; e = QCC_PR_Expression(TOP_PRIORITY); - while (QCC_PR_Check(",")) //logicops, string ops? + while (QCC_PR_CheckToken(",")) //logicops, string ops? { e = QCC_PR_Statement(pr_opcodes+OP_AND, e, QCC_PR_Expression(TOP_PRIORITY), NULL); } @@ -4634,13 +4664,13 @@ void QCC_PR_ParseStatement (void) else e = NULL; - if (!QCC_PR_Check(")")) + if (!QCC_PR_CheckToken(")")) { old_numstatements = numstatements; do { QCC_FreeTemp(QCC_PR_Expression(TOP_PRIORITY)); - } while (QCC_PR_Check(",")); + } while (QCC_PR_CheckToken(",")); numtemp = numstatements - old_numstatements; if (numtemp > sizeof(linenum)/sizeof(linenum[0])) @@ -4661,7 +4691,7 @@ void QCC_PR_ParseStatement (void) QCC_FreeTemp(QCC_PR_Statement(&pr_opcodes[OP_IFNOT], e, 0, &patch1)); else patch1 = NULL; - if (!QCC_PR_Check(";")) + if (!QCC_PR_CheckToken(";")) QCC_PR_ParseStatement(); //don't give the hanging ';' warning. patch3 = &statements[numstatements]; for (i = 0 ; i < numtemp ; i++) @@ -4694,7 +4724,7 @@ void QCC_PR_ParseStatement (void) return; } - if (keyword_do && QCC_PR_Check("do")) + if (QCC_PR_CheckKeyword(keyword_do, "do")) { continues = num_continues; breaks = num_breaks; @@ -4753,7 +4783,7 @@ void QCC_PR_ParseStatement (void) return; } - if (QCC_PR_Check("local")) + if (QCC_PR_CheckKeyword(keyword_local, "local")) { // if (locals_end != numpr_globals) //is this breaking because of locals? // QCC_PR_ParseWarning("local vars after temp vars\n"); @@ -4780,14 +4810,14 @@ void QCC_PR_ParseStatement (void) return; } - if (keyword_state && QCC_PR_Check("state")) + if (QCC_PR_CheckKeyword(keyword_state, "state")) { QCC_PR_Expect("["); QCC_PR_ParseState(); QCC_PR_Expect(";"); return; } - if (QCC_PR_Check("#")) + if (QCC_PR_CheckToken("#")) { char *name; float frame = pr_immediate._float; @@ -4798,9 +4828,9 @@ void QCC_PR_ParseStatement (void) return; } - if (QCC_PR_Check("if")) + if (QCC_PR_CheckKeyword(keyword_if, "if")) { - if (QCC_PR_Check("not")) + if (QCC_PR_CheckKeyword(keyword_not, "not")) { QCC_PR_Expect ("("); conditional = 1; @@ -4835,7 +4865,7 @@ void QCC_PR_ParseStatement (void) QCC_PR_ParseStatement (); - if (QCC_PR_Check ("else")) + if (QCC_PR_CheckKeyword (keyword_else, "else")) { int lastwasreturn; lastwasreturn = statements[numstatements-1].op == OP_RETURN || statements[numstatements-1].op == OP_DONE; @@ -4862,7 +4892,7 @@ void QCC_PR_ParseStatement (void) return; } - if (keyword_switch && QCC_PR_Check("switch")) + if (QCC_PR_CheckKeyword(keyword_switch, "switch")) { int op; int hcstyle; @@ -5087,11 +5117,11 @@ void QCC_PR_ParseStatement (void) return; } - if (keyword_asm && QCC_PR_Check("asm")) + if (QCC_PR_CheckKeyword(keyword_asm, "asm")) { - if (QCC_PR_Check("{")) + if (QCC_PR_CheckToken("{")) { - while (!QCC_PR_Check("}")) + while (!QCC_PR_CheckToken("}")) QCC_PR_ParseAsm (); } else @@ -5099,7 +5129,7 @@ void QCC_PR_ParseStatement (void) return; } - if (QCC_PR_Check(":")) + if (QCC_PR_CheckToken(":")) { if (pr_token_type != tt_name) { @@ -5131,7 +5161,7 @@ void QCC_PR_ParseStatement (void) QCC_PR_Lex(); return; } - if (keyword_goto && QCC_PR_Check("goto")) + if (QCC_PR_CheckKeyword(keyword_goto, "goto")) { if (pr_token_type != tt_name) { @@ -5149,7 +5179,7 @@ void QCC_PR_ParseStatement (void) return; } - if (keyword_break && QCC_PR_Check("break")) + if (QCC_PR_CheckKeyword(keyword_break, "break")) { if (!STRCMP ("(", pr_token)) { //make sure it wasn't a call to the break function. @@ -5170,7 +5200,7 @@ void QCC_PR_ParseStatement (void) return; } } - if (keyword_continue && QCC_PR_Check("continue")) + if (QCC_PR_CheckKeyword(keyword_continue, "continue")) { if (num_continues >= max_continues) { @@ -5183,7 +5213,7 @@ void QCC_PR_ParseStatement (void) QCC_PR_Expect(";"); return; } - if (keyword_case && QCC_PR_Check("case")) + if (QCC_PR_CheckKeyword(keyword_case, "case")) { if (num_cases >= max_cases) { @@ -5194,7 +5224,7 @@ void QCC_PR_ParseStatement (void) } pr_cases[num_cases] = numstatements; pr_casesdef[num_cases] = QCC_PR_Expression (TOP_PRIORITY); - if (QCC_PR_Check("..")) + if (QCC_PR_CheckToken("..")) { pr_casesdef2[num_cases] = QCC_PR_Expression (TOP_PRIORITY); if (pr_casesdef[num_cases]->constant && pr_casesdef2[num_cases]->constant && @@ -5211,7 +5241,7 @@ void QCC_PR_ParseStatement (void) QCC_PR_Expect(":"); return; } - if (keyword_default && QCC_PR_Check("default")) + if (QCC_PR_CheckKeyword(keyword_default, "default")) { if (num_cases >= max_cases) { @@ -5228,7 +5258,7 @@ void QCC_PR_ParseStatement (void) return; } - if (keyword_thinktime && QCC_PR_Check("thinktime")) + if (QCC_PR_CheckKeyword(keyword_thinktime, "thinktime")) { QCC_def_t *nextthink; QCC_def_t *time; @@ -5255,7 +5285,7 @@ void QCC_PR_ParseStatement (void) QCC_PR_Expect(";"); return; } - if (QCC_PR_Check(";")) + if (QCC_PR_CheckToken(";")) { QCC_PR_ParseWarning(WARN_POINTLESSSTATEMENT, "Hanging ';'"); return; @@ -5301,7 +5331,7 @@ void QCC_PR_ParseState (void) char f; f = *pr_token; - if (QCC_PR_Check("++") || QCC_PR_Check("--")) + if (QCC_PR_CheckToken("++") || QCC_PR_CheckToken("--")) { s1 = QCC_PR_ParseImmediate (); QCC_PR_Expect(".."); @@ -5378,7 +5408,7 @@ void QCC_PR_ParseState (void) QCC_PR_ParseError (ERR_STATETYPEMISMATCH, "state frame must be a number"); s1 = QCC_PR_ParseImmediate (); - QCC_PR_Check (","); + QCC_PR_CheckToken (","); name = QCC_PR_ParseName (); pr_scope = NULL; @@ -5396,7 +5426,7 @@ void QCC_PR_ParseAsm(void) int op, p; QCC_def_t *a, *b, *c; - if (QCC_PR_Check("local")) + if (QCC_PR_CheckKeyword(keyword_local, "local")) { QCC_PR_ParseDefs (NULL); locals_end = numpr_globals; @@ -6107,7 +6137,7 @@ QCC_function_t *QCC_PR_ParseImmediateStatements (QCC_type_t *type) // check for builtin function definition #1, #2, etc // // hexenC has void name() : 2; - if (QCC_PR_Check ("#") || QCC_PR_Check (":")) + if (QCC_PR_CheckToken ("#") || QCC_PR_CheckToken (":")) { if (pr_token_type != tt_immediate || pr_immediate_type != type_float @@ -6119,7 +6149,7 @@ QCC_function_t *QCC_PR_ParseImmediateStatements (QCC_type_t *type) locals_start = locals_end = OFS_PARM0; //hmm... return f; } - if (QCC_PR_Check("external")) + if (QCC_PR_CheckKeyword(keyword_external, "external")) { //reacc style builtin if (pr_token_type != tt_immediate || pr_immediate_type != type_float @@ -6204,18 +6234,18 @@ QCC_function_t *QCC_PR_ParseImmediateStatements (QCC_type_t *type) // // check for a state opcode // - if (QCC_PR_Check ("[")) + if (QCC_PR_CheckToken ("[")) QCC_PR_ParseState (); - if (QCC_PR_Check ("asm")) + if (QCC_PR_CheckKeyword (keyword_asm, "asm")) { QCC_PR_Expect ("{"); - while (!QCC_PR_Check("}")) + while (!QCC_PR_CheckToken("}")) QCC_PR_ParseAsm (); } else { - if (QCC_PR_CheckInsens ("var")) //reacc support + if (QCC_PR_CheckKeyword (keyword_var, "var")) //reacc support { //parse lots of locals char *name; do { @@ -6223,14 +6253,14 @@ QCC_function_t *QCC_PR_ParseImmediateStatements (QCC_type_t *type) QCC_PR_Expect(":"); e2 = QCC_PR_GetDef(QCC_PR_ParseType(false), name, pr_scope, true, 1); QCC_PR_Expect(";"); - } while(!QCC_PR_Check("{")); + } while(!QCC_PR_CheckToken("{")); } else QCC_PR_Expect ("{"); // // parse regular statements // - while (!QCC_PR_Check("}")) + while (!QCC_PR_CheckToken("}")) { QCC_PR_ParseStatement (); QCC_FreeTemps(); @@ -6632,7 +6662,6 @@ QCC_def_t *QCC_PR_DummyDef(QCC_type_t *type, char *name, QCC_def_t *scope, int a KEYWORD(switch); KEYWORD(case); KEYWORD(default); - KEYWORD(do); KEYWORD(goto); if (type->type != ev_function) KEYWORD(break); @@ -7130,7 +7159,7 @@ void QCC_PR_ParseDefs (char *classname) gofs_t oldglobals; int arraysize; - if (QCC_PR_Check("enum")) + if (QCC_PR_CheckKeyword(keyword_enum, "enum")) { float v = 0; QCC_PR_Expect("{"); @@ -7139,7 +7168,7 @@ void QCC_PR_ParseDefs (char *classname) while(1) { name = QCC_PR_ParseName(); - if (QCC_PR_Check("=")) + if (QCC_PR_CheckToken("=")) { if (pr_token_type != tt_immediate && pr_immediate_type->type != ev_float) { @@ -7165,7 +7194,7 @@ void QCC_PR_ParseDefs (char *classname) G_FLOAT(def->ofs) = v; v++; - if (QCC_PR_Check("}")) + if (QCC_PR_CheckToken("}")) break; QCC_PR_Expect(","); } @@ -7173,7 +7202,7 @@ void QCC_PR_ParseDefs (char *classname) return; } - if (QCC_PR_Check("enumflags")) + if (QCC_PR_CheckKeyword(keyword_enumflags, "enumflags")) { float v = 1; int bits; @@ -7183,7 +7212,7 @@ void QCC_PR_ParseDefs (char *classname) while(1) { name = QCC_PR_ParseName(); - if (QCC_PR_Check("=")) + if (QCC_PR_CheckToken("=")) { if (pr_token_type != tt_immediate && pr_immediate_type->type != ev_float) { @@ -7225,7 +7254,7 @@ void QCC_PR_ParseDefs (char *classname) G_FLOAT(def->ofs) = v; v*=2; - if (QCC_PR_Check("}")) + if (QCC_PR_CheckToken("}")) break; QCC_PR_Expect(","); } @@ -7233,7 +7262,7 @@ void QCC_PR_ParseDefs (char *classname) return; } - if (QCC_PR_Check ("typedef")) + if (QCC_PR_CheckKeyword (keyword_typedef, "typedef")) { type = QCC_PR_ParseType(true); if (!type) @@ -7249,7 +7278,7 @@ void QCC_PR_ParseDefs (char *classname) if (flag_acc) { char *oldp; - if (QCC_PR_CheckInsens ("CodeSys")) //reacc support. + if (QCC_PR_CheckKeyword (keyword_codesys, "CodeSys")) //reacc support. { extern int ForcedCRC; if (ForcedCRC) @@ -7261,7 +7290,7 @@ void QCC_PR_ParseDefs (char *classname) } oldp = pr_file_p; - if (QCC_PR_CheckInsens ("var")) //reacc support. + if (QCC_PR_CheckKeyword (keyword_var, "var")) //reacc support. { if (accglobalsblock == 3) { @@ -7270,17 +7299,17 @@ void QCC_PR_ParseDefs (char *classname) } QCC_PR_ParseName(); - if (QCC_PR_Check(":")) + if (QCC_PR_CheckToken(":")) accglobalsblock = 1; pr_file_p = oldp; QCC_PR_Lex(); } - if (QCC_PR_CheckInsens ("function")) //reacc support. + if (QCC_PR_CheckKeyword (keyword_function, "function")) //reacc support. { accglobalsblock = 2; } - if (QCC_PR_CheckInsens ("objdata")) //reacc support. + if (QCC_PR_CheckKeyword (keyword_objdata, "objdata")) //reacc support. { if (accglobalsblock == 3) { @@ -7301,7 +7330,7 @@ void QCC_PR_ParseDefs (char *classname) { char *oldp = pr_file_p; name = QCC_PR_ParseName(); - if (!QCC_PR_Check(":")) //nope, it wasn't! + if (!QCC_PR_CheckToken(":")) //nope, it wasn't! { QCC_PR_IncludeChunk(name, true, NULL); QCC_PR_Lex(); @@ -7309,23 +7338,23 @@ void QCC_PR_ParseDefs (char *classname) pr_file_p = oldp; break; } - if (QCC_PR_CheckInsens("Object")) + if (QCC_PR_CheckKeyword(keyword_object, "object")) QCC_PR_GetDef(type_entity, name, NULL, true, 1); - else if (QCC_PR_CheckInsens("String")) + else if (QCC_PR_CheckKeyword(keyword_string, "string")) QCC_PR_GetDef(type_string, name, NULL, true, 1); - else if (QCC_PR_CheckInsens("Real")) + else if (QCC_PR_CheckKeyword(keyword_real, "real")) { def = QCC_PR_GetDef(type_float, name, NULL, true, 1); - if (QCC_PR_Check("=")) + if (QCC_PR_CheckToken("=")) { G_FLOAT(def->ofs) = pr_immediate._float; QCC_PR_Lex(); } } - else if (QCC_PR_CheckInsens("Vector")) + else if (QCC_PR_CheckKeyword(keyword_vector, "vector")) { def = QCC_PR_GetDef(type_vector, name, NULL, true, 1); - if (QCC_PR_Check("=")) + if (QCC_PR_CheckToken("=")) { QCC_PR_Expect("["); G_FLOAT(def->ofs+0) = pr_immediate._float; @@ -7337,26 +7366,26 @@ void QCC_PR_ParseDefs (char *classname) QCC_PR_Expect("]"); } } - else if (QCC_PR_CheckInsens("PFunc")) + else if (QCC_PR_CheckKeyword(keyword_pfunc, "pfunc")) QCC_PR_GetDef(type_function, name, NULL, true, 1); else QCC_PR_ParseError(ERR_BADNOTTYPE, "Bad type\n"); QCC_PR_Expect (";"); - if (QCC_PR_Check ("system")) + if (QCC_PR_CheckKeyword (keyword_system, "system")) QCC_PR_Expect (";"); return; } case 2: name = QCC_PR_ParseName(); QCC_PR_GetDef(type_function, name, NULL, true, 1); - QCC_PR_Check (";"); + QCC_PR_CheckToken (";"); return; case 3: { char *oldp = pr_file_p; name = QCC_PR_ParseName(); - if (!QCC_PR_Check(":")) //nope, it wasn't! + if (!QCC_PR_CheckToken(":")) //nope, it wasn't! { QCC_PR_IncludeChunk(name, true, NULL); QCC_PR_Lex(); @@ -7364,15 +7393,15 @@ void QCC_PR_ParseDefs (char *classname) pr_file_p = oldp; break; } - if (QCC_PR_CheckInsens("Object")) + if (QCC_PR_CheckKeyword(keyword_object, "object")) QCC_PR_GetDef(QCC_PR_FieldType(type_entity), name, NULL, true, 1); - else if (QCC_PR_CheckInsens("String")) + else if (QCC_PR_CheckKeyword(keyword_string, "string")) QCC_PR_GetDef(QCC_PR_FieldType(type_string), name, NULL, true, 1); - else if (QCC_PR_CheckInsens("real")) + else if (QCC_PR_CheckKeyword(keyword_real, "real")) QCC_PR_GetDef(QCC_PR_FieldType(type_float), name, NULL, true, 1); - else if (QCC_PR_CheckInsens("vector")) + else if (QCC_PR_CheckKeyword(keyword_vector, "vector")) QCC_PR_GetDef(QCC_PR_FieldType(type_vector), name, NULL, true, 1); - else if (QCC_PR_CheckInsens("pfunc")) + else if (QCC_PR_CheckKeyword(keyword_pfunc, "pfunc")) QCC_PR_GetDef(QCC_PR_FieldType(type_function), name, NULL, true, 1); else QCC_PR_ParseError(ERR_BADNOTTYPE, "Bad type\n"); @@ -7383,21 +7412,21 @@ void QCC_PR_ParseDefs (char *classname) while(1) { - if (QCC_PR_Check("extern")) + if (QCC_PR_CheckKeyword(keyword_extern, "extern")) externfnc=true; - else if (QCC_PR_Check("shared")) + else if (QCC_PR_CheckKeyword(keyword_shared, "shared")) { shared=true; if (pr_scope) QCC_PR_ParseError (ERR_NOSHAREDLOCALS, "Cannot have shared locals"); } - else if (QCC_PR_Check("const")) + else if (QCC_PR_CheckKeyword(keyword_const, "const")) constant = true; - else if (QCC_PR_Check("var")) + else if (QCC_PR_CheckKeyword(keyword_var, "var")) constant = false; - else if (QCC_PR_Check("noref")) + else if (QCC_PR_CheckKeyword(keyword_noref, "noref")) noref=true; - else if (QCC_PR_Check("nosave")) + else if (QCC_PR_CheckKeyword(keyword_nosave, "nosave")) nosave = true; else break; @@ -7413,7 +7442,7 @@ void QCC_PR_ParseDefs (char *classname) externfnc=false; } - if (!pr_scope && QCC_PR_CheckInsens("function")) //reacc support. + if (!pr_scope && QCC_PR_CheckKeyword(keyword_function, "function")) //reacc support. { name = QCC_PR_ParseName (); QCC_PR_Expect("("); @@ -7426,7 +7455,7 @@ void QCC_PR_ParseDefs (char *classname) if (autoprototype) { //ignore the code and stuff - if (QCC_PR_Check("external")) + if (QCC_PR_CheckKeyword(keyword_external, "external")) { //builtin QCC_PR_Lex(); QCC_PR_Expect(";"); @@ -7435,7 +7464,7 @@ void QCC_PR_ParseDefs (char *classname) { int blev = 1; - while (!QCC_PR_Check("{")) //skip over the locals. + while (!QCC_PR_CheckToken("{")) //skip over the locals. { if (pr_token_type == tt_eof) { @@ -7450,9 +7479,9 @@ void QCC_PR_ParseDefs (char *classname) { if (pr_token_type == tt_eof) break; - if (QCC_PR_Check("{")) + if (QCC_PR_CheckToken("{")) blev++; - else if (QCC_PR_Check("}")) + else if (QCC_PR_CheckToken("}")) blev--; else QCC_PR_Lex(); //ignore it. @@ -7501,14 +7530,14 @@ void QCC_PR_ParseDefs (char *classname) do { - if (QCC_PR_Check ("*")) + if (QCC_PR_CheckToken ("*")) { ispointer = 1; - while(QCC_PR_Check ("*")) + while(QCC_PR_CheckToken ("*")) ispointer++; name = QCC_PR_ParseName (); } - else if (QCC_PR_Check (";")) + else if (QCC_PR_CheckToken (";")) { if (type->type == ev_field && (type->aux_type->type == ev_union || type->aux_type->type == ev_struct)) { @@ -7529,7 +7558,7 @@ void QCC_PR_ParseDefs (char *classname) ispointer = false; } - if (QCC_PR_Check("::") && !classname) + if (QCC_PR_CheckToken("::") && !classname) { classname = name; name = QCC_PR_ParseName(); @@ -7537,11 +7566,11 @@ void QCC_PR_ParseDefs (char *classname) //check for an array - if ( QCC_PR_Check ("[") ) + if ( QCC_PR_CheckToken ("[") ) { char *oldprfile = pr_file_p; arraysize = 0; - if (QCC_PR_Check("]")) + if (QCC_PR_CheckToken("]")) { QCC_PR_Expect("="); QCC_PR_Expect("{"); @@ -7551,9 +7580,9 @@ void QCC_PR_ParseDefs (char *classname) { if(pr_token_type == tt_eof) break; - if (QCC_PR_Check(",")) + if (QCC_PR_CheckToken(",")) arraysize++; - if (QCC_PR_Check("}")) + if (QCC_PR_CheckToken("}")) break; QCC_PR_Lex(); } @@ -7590,7 +7619,7 @@ void QCC_PR_ParseDefs (char *classname) else arraysize = 1; - if (QCC_PR_Check("(")) + if (QCC_PR_CheckToken("(")) type = QCC_PR_ParseFunctionType(false, type); if (classname) @@ -7645,7 +7674,7 @@ void QCC_PR_ParseDefs (char *classname) // check for an initialization if (type->type == ev_function && (pr_scope || !constant)) { - if ( QCC_PR_Check ("=") ) + if ( QCC_PR_CheckToken ("=") ) { if (def->arraysize>1) goto lazyfunctiondeclaration; @@ -7664,12 +7693,12 @@ void QCC_PR_ParseDefs (char *classname) continue; } - if (type->type == ev_field && QCC_PR_Check ("alias")) + if (type->type == ev_field && QCC_PR_CheckToken ("alias")) { QCC_PR_ParseError(ERR_INTERNAL, "FTEQCC does not support this variant of decompiled hexenc\nPlease obtain the origional version released by Raven Software instead."); name = QCC_PR_ParseName(); } - else if ( QCC_PR_Check ("=") || ((type->type == ev_function) && (pr_token[0] == '{' || pr_token[0] == '[' || pr_token[0] == ':'))) //this is an initialisation (or a function) + else if ( QCC_PR_CheckToken ("=") || ((type->type == ev_function) && (pr_token[0] == '{' || pr_token[0] == '[' || pr_token[0] == ':'))) //this is an initialisation (or a function) { if (def->shared) QCC_PR_ParseError (ERR_SHAREDINITIALISED, "shared values may not be assigned an initial value", name); @@ -7687,16 +7716,16 @@ void QCC_PR_ParseDefs (char *classname) if (autoprototype) { //ignore the code and stuff - if (QCC_PR_Check("[")) + if (QCC_PR_CheckToken("[")) { - while (!QCC_PR_Check("]")) + while (!QCC_PR_CheckToken("]")) { if (pr_token_type == tt_eof) break; QCC_PR_Lex(); } } - if (QCC_PR_Check("{")) + if (QCC_PR_CheckToken("{")) { int blev = 1; //balance out the { and } @@ -7704,9 +7733,9 @@ void QCC_PR_ParseDefs (char *classname) { if (pr_token_type == tt_eof) break; - if (QCC_PR_Check("{")) + if (QCC_PR_CheckToken("{")) blev++; - else if (QCC_PR_Check("}")) + else if (QCC_PR_CheckToken("}")) blev--; else QCC_PR_Lex(); //ignore it. @@ -7714,7 +7743,7 @@ void QCC_PR_ParseDefs (char *classname) } else { - QCC_PR_Check("#"); + QCC_PR_CheckToken("#"); QCC_PR_Lex(); } continue; @@ -7744,7 +7773,7 @@ void QCC_PR_ParseDefs (char *classname) { lazyfunctiondeclaration: def->constant = constant; - if (QCC_PR_Check("0")) + if (QCC_PR_CheckToken("0")) { def->constant = 0; def->initialized = 1; //fake function @@ -7760,7 +7789,7 @@ lazyfunctiondeclaration: i = 0; do { - if (QCC_PR_Check("0")) + if (QCC_PR_CheckToken("0")) G_FUNCTION(def->ofs+i) = 0; else { @@ -7778,7 +7807,7 @@ lazyfunctiondeclaration: } i++; - } while(QCC_PR_Check(",")); + } while(QCC_PR_CheckToken(",")); arraysize = def->arraysize; d = def; //apply to ALL elements @@ -7852,7 +7881,7 @@ lazyfunctiondeclaration: case ev_vector: if (pr_token_type == tt_punct) { - if (QCC_PR_Check("{")) + if (QCC_PR_CheckToken("{")) { QCC_PR_Expect("}"); } @@ -7889,7 +7918,7 @@ lazyfunctiondeclaration: case ev_string: if (pr_token_type == tt_punct) { - if (QCC_PR_Check("{")) + if (QCC_PR_CheckToken("{")) { unsigned int i; for (i = 0; i < parttype->size; i++) @@ -7912,7 +7941,7 @@ lazyfunctiondeclaration: G_INT(def->ofs+arraypart*type->size+parttype->ofs+i) = QCC_CopyString(pr_immediate_string); QCC_PR_Lex (); - if (!QCC_PR_Check(",")) + if (!QCC_PR_CheckToken(",")) { i++; break; @@ -7987,13 +8016,13 @@ lazyfunctiondeclaration: QCC_PR_Lex(); break; } - if (!QCC_PR_Check(",")) + if (!QCC_PR_CheckToken(",")) break; parttype=parttype->next; } QCC_PR_Expect("}"); - if (!QCC_PR_Check(",")) + if (!QCC_PR_CheckToken(",")) break; } QCC_PR_Expect("}"); @@ -8016,7 +8045,7 @@ lazyfunctiondeclaration: } else if (type->type == ev_string) { - if (arraysize>=1 && QCC_PR_Check("{")) + if (arraysize>=1 && QCC_PR_CheckToken("{")) { int i; for (i = 0; i < arraysize; i++) @@ -8044,7 +8073,7 @@ lazyfunctiondeclaration: (((int *)qcc_pr_globals)[def->ofs+i]) = QCC_CopyString(pr_immediate_string); QCC_PR_Lex (); - if (!QCC_PR_Check(",")) + if (!QCC_PR_CheckToken(",")) break; } QCC_PR_Expect("}"); @@ -8070,7 +8099,7 @@ lazyfunctiondeclaration: } else if (type->type == ev_float) { - if (arraysize>=1 && QCC_PR_Check("{")) + if (arraysize>=1 && QCC_PR_CheckToken("{")) { int i; for (i = 0; i < arraysize; i++) @@ -8080,7 +8109,7 @@ lazyfunctiondeclaration: (((float *)qcc_pr_globals)[def->ofs+i]) = pr_immediate._float; QCC_PR_Lex (); - if (!QCC_PR_Check(",")) + if (!QCC_PR_CheckToken(",")) break; } QCC_PR_Expect("}"); @@ -8120,7 +8149,7 @@ lazyfunctiondeclaration: } else if (type->type == ev_vector) { - if (arraysize>=1 && QCC_PR_Check("{")) + if (arraysize>=1 && QCC_PR_CheckToken("{")) { int i; for (i = 0; i < arraysize; i++) @@ -8132,7 +8161,7 @@ lazyfunctiondeclaration: (((float *)qcc_pr_globals)[def->ofs+i*3+2]) = pr_immediate.vector[2]; QCC_PR_Lex (); - if (!QCC_PR_Check(",")) + if (!QCC_PR_CheckToken(",")) break; } QCC_PR_Expect("}"); @@ -8190,12 +8219,15 @@ lazyfunctiondeclaration: QCC_PR_Lex (); } - } while (QCC_PR_Check (",")); + } while (QCC_PR_CheckToken (",")); if (type->type == ev_function) - QCC_PR_Check (";"); + QCC_PR_CheckToken (";"); else - QCC_PR_Expect (";"); + { + if (!QCC_PR_CheckToken (";")) + QCC_PR_ParseWarning(WARN_UNDESIRABLECONVENTION, "Missing semicolon at end of definition"); + } } /* diff --git a/engine/qclib/qcc_pr_lex.c b/engine/qclib/qcc_pr_lex.c index 51f90e2b8..1dd37416e 100644 --- a/engine/qclib/qcc_pr_lex.c +++ b/engine/qclib/qcc_pr_lex.c @@ -935,8 +935,13 @@ void QCC_PR_LexString (void) else if (c == '\'') c = '\''; else if (c >= '0' && c <= '9') - c = (int)QCC_PR_LexOctal(); - + c = 18 + c - '0'; + else if (c >= '0' && c <= '8') + { //octal + c = c - '0'; + while(*pr_file_p >= '0' && *pr_file_p <= '8') + c = (c<<3) | (*pr_file_p++ - '0'); + } else if (c == '\r') { //sigh c = *pr_file_p++; @@ -2367,7 +2372,7 @@ Returns false and does nothing otherwise ============= */ #ifndef COMMONINLINES -pbool QCC_PR_Check (char *string) +pbool QCC_PR_CheckToken (char *string) { if (STRCMP (string, pr_token)) return false; @@ -2375,17 +2380,43 @@ pbool QCC_PR_Check (char *string) QCC_PR_Lex (); return true; } -#endif -pbool QCC_PR_CheckInsens (char *string) +pbool QCC_PR_CheckName(char *string) { - if (stricmp (string, pr_token)) - return false; - + if (flag_caseinsensative) + { + if (stricmp (string, pr_token)) + return false; + } + else + { + if (STRCMP(string, pr_token)) + return false; + } QCC_PR_Lex (); return true; } +pbool QCC_PR_CheckKeyword(int keywordenabled, char *string) +{ + if (!keywordenabled) + return false; + if (flag_caseinsensative) + { + if (stricmp (string, pr_token)) + return false; + } + else + { + if (STRCMP(string, pr_token)) + return false; + } + QCC_PR_Lex (); + return true; +} +#endif + + /* ============ PR_ParseName @@ -2622,7 +2653,7 @@ void QCC_PR_SkipToSemicolon (void) { do { - if (!pr_bracelevel && QCC_PR_Check (";")) + if (!pr_bracelevel && QCC_PR_CheckToken (";")) return; QCC_PR_Lex (); } while (pr_token_type != tt_eof); @@ -2661,9 +2692,9 @@ QCC_type_t *QCC_PR_ParseFunctionType (int newtype, QCC_type_t *returntype) ptype = NULL; - if (!QCC_PR_Check (")")) + if (!QCC_PR_CheckToken (")")) { - if (QCC_PR_Check ("...")) + if (QCC_PR_CheckToken ("...")) ftype->num_parms = -1; // variable args else do @@ -2671,7 +2702,7 @@ QCC_type_t *QCC_PR_ParseFunctionType (int newtype, QCC_type_t *returntype) if (ftype->num_parms>=MAX_PARMS+MAX_EXTRA_PARMS) QCC_PR_ParseError(ERR_TOOMANYTOTALPARAMETERS, "Too many parameters. Sorry. (limit is %i)\n", MAX_PARMS+MAX_EXTRA_PARMS); - if (QCC_PR_Check ("...")) + if (QCC_PR_CheckToken ("...")) { ftype->num_parms = (ftype->num_parms * -1) - 1; break; @@ -2703,7 +2734,7 @@ QCC_type_t *QCC_PR_ParseFunctionType (int newtype, QCC_type_t *returntype) else if (definenames) strcpy (pr_parm_names[ftype->num_parms], ""); ftype->num_parms++; - } while (QCC_PR_Check (",")); + } while (QCC_PR_CheckToken (",")); QCC_PR_Expect (")"); } @@ -2730,9 +2761,9 @@ QCC_type_t *QCC_PR_ParseFunctionTypeReacc (int newtype, QCC_type_t *returntype) ptype = NULL; - if (!QCC_PR_Check (")")) + if (!QCC_PR_CheckToken (")")) { - if (QCC_PR_Check ("...")) + if (QCC_PR_CheckToken ("...")) ftype->num_parms = -1; // variable args else do @@ -2740,19 +2771,19 @@ QCC_type_t *QCC_PR_ParseFunctionTypeReacc (int newtype, QCC_type_t *returntype) if (ftype->num_parms>=MAX_PARMS+MAX_EXTRA_PARMS) QCC_PR_ParseError(ERR_TOOMANYTOTALPARAMETERS, "Too many parameters. Sorry. (limit is %i)\n", MAX_PARMS+MAX_EXTRA_PARMS); - if (QCC_PR_Check ("...")) + if (QCC_PR_CheckToken ("...")) { ftype->num_parms = (ftype->num_parms * -1) - 1; break; } - if (QCC_PR_Check("arg")) + if (QCC_PR_CheckToken("arg")) { sprintf(argname, "arg%i", ftype->num_parms); name = argname; nptype = QCC_PR_NewType("Variant", ev_variant); } - else if (QCC_PR_Check("vect")) //this can only be of vector sizes, so... + else if (QCC_PR_CheckToken("vect")) //this can only be of vector sizes, so... { sprintf(argname, "arg%i", ftype->num_parms); name = argname; @@ -2782,7 +2813,7 @@ QCC_type_t *QCC_PR_ParseFunctionTypeReacc (int newtype, QCC_type_t *returntype) if (definenames) strcpy (pr_parm_names[ftype->num_parms], name); ftype->num_parms++; - } while (QCC_PR_Check (";")); + } while (QCC_PR_CheckToken (";")); QCC_PR_Expect (")"); } @@ -2821,7 +2852,7 @@ QCC_type_t *QCC_PR_ParseType (int newtype) // int ofs; - if (QCC_PR_Check ("..")) //so we don't end up with the user specifying '. .vector blah' (hexen2 added the .. token for array ranges) + if (QCC_PR_CheckToken ("..")) //so we don't end up with the user specifying '. .vector blah' (hexen2 added the .. token for array ranges) { newt = QCC_PR_NewType("FIELD TYPE", ev_field); newt->aux_type = QCC_PR_ParseType (false); @@ -2839,7 +2870,7 @@ QCC_type_t *QCC_PR_ParseType (int newtype) return type; return QCC_PR_FindType (type); } - if (QCC_PR_Check (".")) + if (QCC_PR_CheckToken (".")) { newt = QCC_PR_NewType("FIELD TYPE", ev_field); newt->aux_type = QCC_PR_ParseType (false); @@ -2853,7 +2884,7 @@ QCC_type_t *QCC_PR_ParseType (int newtype) name = QCC_PR_CheakCompConstString(pr_token); - if (QCC_PR_Check ("class")) + if (QCC_PR_CheckKeyword (keyword_class, "class")) { // int parms; QCC_type_t *fieldtype; @@ -2864,7 +2895,7 @@ QCC_type_t *QCC_PR_ParseType (int newtype) type = NULL; - if (QCC_PR_Check(":")) + if (QCC_PR_CheckToken(":")) { char *parentname = QCC_PR_ParseName(); newt->parentclass = QCC_TypeForName(parentname); @@ -2876,11 +2907,11 @@ QCC_type_t *QCC_PR_ParseType (int newtype) QCC_PR_Expect("{"); - if (QCC_PR_Check(",")) + if (QCC_PR_CheckToken(",")) QCC_PR_ParseError(ERR_NOTANAME, "member missing name"); - while (!QCC_PR_Check("}")) + while (!QCC_PR_CheckToken("}")) { -// if (QCC_PR_Check(",")) +// if (QCC_PR_CheckToken(",")) // type->next = QCC_PR_NewType(type->name, type->type); // else newparm = QCC_PR_ParseType(true); @@ -2888,17 +2919,17 @@ QCC_type_t *QCC_PR_ParseType (int newtype) if (newparm->type == ev_struct || newparm->type == ev_union) //we wouldn't be able to handle it. QCC_PR_ParseError(ERR_INTERNAL, "Struct or union in class %s", classname); - if (!QCC_PR_Check(";")) + if (!QCC_PR_CheckToken(";")) { newparm->name = QCC_CopyString(pr_token)+strings; QCC_PR_Lex(); - if (QCC_PR_Check("[")) + if (QCC_PR_CheckToken("[")) { type->next->size*=atoi(pr_token); QCC_PR_Lex(); QCC_PR_Expect("]"); } - QCC_PR_Check(";"); + QCC_PR_CheckToken(";"); } else newparm->name = QCC_CopyString("")+strings; @@ -2924,20 +2955,20 @@ QCC_type_t *QCC_PR_ParseType (int newtype) QCC_PR_Expect(";"); return NULL; } - if (QCC_PR_Check ("struct")) + if (QCC_PR_CheckKeyword (keyword_struct, "struct")) { newt = QCC_PR_NewType("struct", ev_struct); newt->size=0; QCC_PR_Expect("{"); type = NULL; - if (QCC_PR_Check(",")) + if (QCC_PR_CheckToken(",")) QCC_PR_ParseError(ERR_NOTANAME, "element missing name"); newparm = NULL; - while (!QCC_PR_Check("}")) + while (!QCC_PR_CheckToken("}")) { - if (QCC_PR_Check(",")) + if (QCC_PR_CheckToken(",")) { if (!newparm) QCC_PR_ParseError(ERR_NOTANAME, "element missing type"); @@ -2946,17 +2977,17 @@ QCC_type_t *QCC_PR_ParseType (int newtype) else newparm = QCC_PR_ParseType(true); - if (!QCC_PR_Check(";")) + if (!QCC_PR_CheckToken(";")) { newparm->name = QCC_CopyString(pr_token)+strings; QCC_PR_Lex(); - if (QCC_PR_Check("[")) + if (QCC_PR_CheckToken("[")) { newparm->size*=atoi(pr_token); QCC_PR_Lex(); QCC_PR_Expect("]"); } - QCC_PR_Check(";"); + QCC_PR_CheckToken(";"); } else newparm->name = QCC_CopyString("")+strings; @@ -2972,19 +3003,19 @@ QCC_type_t *QCC_PR_ParseType (int newtype) } return newt; } - if (QCC_PR_Check ("union")) + if (QCC_PR_CheckKeyword (keyword_union, "union")) { newt = QCC_PR_NewType("union", ev_union); newt->size=0; QCC_PR_Expect("{"); type = NULL; - if (QCC_PR_Check(",")) + if (QCC_PR_CheckToken(",")) QCC_PR_ParseError(ERR_NOTANAME, "element missing name"); newparm = NULL; - while (!QCC_PR_Check("}")) + while (!QCC_PR_CheckToken("}")) { - if (QCC_PR_Check(",")) + if (QCC_PR_CheckToken(",")) { if (!newparm) QCC_PR_ParseError(ERR_NOTANAME, "element missing type"); @@ -2992,7 +3023,7 @@ QCC_type_t *QCC_PR_ParseType (int newtype) } else newparm = QCC_PR_ParseType(true); - if (QCC_PR_Check(";")) + if (QCC_PR_CheckToken(";")) newparm->name = QCC_CopyString("")+strings; else { @@ -3047,7 +3078,7 @@ QCC_type_t *QCC_PR_ParseType (int newtype) } QCC_PR_Lex (); - if (QCC_PR_Check ("(")) //this is followed by parameters. Must be a function. + if (QCC_PR_CheckToken ("(")) //this is followed by parameters. Must be a function. return QCC_PR_ParseFunctionType(newtype, type); else { diff --git a/engine/qclib/qccgui.c b/engine/qclib/qccgui.c index 27b945c3f..99fb2c0a0 100644 --- a/engine/qclib/qccgui.c +++ b/engine/qclib/qccgui.c @@ -32,11 +32,14 @@ void RunCompiler(char *args); HINSTANCE ghInstance; HMODULE richedit; +pbool resetprogssrc; //progs.src was changed, reload project info. + HWND mainwindow; HWND mdibox; HWND outputwindow; HWND outputbox; +HWND projecttree; FILE *logfile; @@ -67,10 +70,12 @@ void GUI_DialogPrint(char *title, char *text) HWND CreateAnEditControl(HWND parent) { + HWND newc; + if (!richedit) richedit = LoadLibrary("RICHED32.DLL"); - outputbox=CreateWindowEx(WS_EX_CLIENTEDGE, + newc=CreateWindowEx(WS_EX_CLIENTEDGE, richedit?RICHEDIT_CLASS:"EDIT", "", WS_CHILD /*| ES_READONLY*/ | WS_VISIBLE | @@ -82,8 +87,8 @@ HWND CreateAnEditControl(HWND parent) ghInstance, NULL); - if (!outputbox) - outputbox=CreateWindowEx(WS_EX_CLIENTEDGE, + if (!newc) + newc=CreateWindowEx(WS_EX_CLIENTEDGE, richedit?RICHEDIT_CLASS10A:"EDIT", //fall back to the earlier version "", WS_CHILD /*| ES_READONLY*/ | WS_VISIBLE | @@ -95,11 +100,11 @@ HWND CreateAnEditControl(HWND parent) ghInstance, NULL); - if (!outputbox) + if (!newc) { //you've not got RICHEDIT installed properly, I guess FreeLibrary(richedit); richedit = NULL; - outputbox=CreateWindowEx(WS_EX_CLIENTEDGE, + newc=CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "", WS_CHILD /*| ES_READONLY*/ | WS_VISIBLE | @@ -112,14 +117,26 @@ HWND CreateAnEditControl(HWND parent) NULL); } - if (richedit) + //go to lucidia console, 10pt { - SendMessage(outputbox, EM_EXLIMITTEXT, 0, 1<<20); + CHARFORMAT cf; + memset(&cf, 0, sizeof(cf)); + cf.cbSize = sizeof(cf); + cf.dwMask = CFM_BOLD | CFM_FACE;// | CFM_SIZE; + strcpy(cf.szFaceName, "Lucida Console"); + cf.yHeight = 5; + + SendMessage(newc, EM_SETCHARFORMAT, SCF_ALL, (WPARAM)&cf); } - ShowWindow(outputbox, SW_SHOW); + if (richedit) + { + SendMessage(newc, EM_EXLIMITTEXT, 0, 1<<20); + } - return outputbox; + ShowWindow(newc, SW_SHOW); + + return newc; } @@ -328,6 +345,8 @@ static LONG CALLBACK EditorWndProc(HWND hWnd,UINT message, } goto gdefault; case WM_CREATE: + editor->editpane = CreateAnEditControl(hWnd); + /* editor->editpane=CreateWindowEx(WS_EX_CLIENTEDGE, richedit?RICHEDIT_CLASS:"EDIT", "", @@ -339,7 +358,7 @@ static LONG CALLBACK EditorWndProc(HWND hWnd,UINT message, NULL, ghInstance, NULL); - +*/ if (richedit) { SendMessage(editor->editpane, EM_EXLIMITTEXT, 0, 1<<31); @@ -1045,6 +1064,7 @@ static LONG CALLBACK OptionsWndProc(HWND hWnd,UINT message, SetCurrentDirectory(progssrcdir); *progssrcdir = '\0'; } + resetprogssrc = true; } break; case IDI_O_LEVEL0: @@ -1371,7 +1391,7 @@ void OptionsDialog(void) compiler_flag[i].guiinfo = wnd = CreateWindow("BUTTON",compiler_flag[i].fullname, WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, - x,y,200-16,16, + x,y,168,16, optionsmenu, (HMENU)IDI_O_COMPILER_FLAG, ghInstance, @@ -1471,8 +1491,13 @@ static LONG CALLBACK MainWndProc(HWND hWnd,UINT message, mdibox = CreateWindow( "MDICLIENT", (LPCTSTR) NULL, WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL, 0, 0, 320, 200, hWnd, (HMENU) 0xCAC, ghInstance, (LPSTR) &ccs); + ShowWindow(mdibox, SW_SHOW); - ShowWindow(mdibox, SW_SHOW); + projecttree = CreateWindow(WC_TREEVIEW, (LPCTSTR) NULL, + WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL + | TVS_HASBUTTONS |TVS_LINESATROOT|TVS_HASLINES, + 0, 0, 320, 200, hWnd, (HMENU) 0xCAC, ghInstance, (LPSTR) &ccs); + ShowWindow(projecttree, SW_SHOW); } break; @@ -1482,7 +1507,13 @@ static LONG CALLBACK MainWndProc(HWND hWnd,UINT message, case WM_SIZE: GetClientRect(mainwindow, &rect); - SetWindowPos(mdibox?mdibox:outputbox, NULL, 0, 0, rect.right-rect.left, rect.bottom-rect.top - 32, 0); + if (projecttree) + { + SetWindowPos(projecttree, NULL, 0, 0, 192, rect.bottom-rect.top - 32, 0); + SetWindowPos(mdibox?mdibox:outputbox, NULL, 192, 0, rect.right-rect.left-192, rect.bottom-rect.top - 32, 0); + } + else + SetWindowPos(mdibox?mdibox:outputbox, NULL, 0, 0, rect.right-rect.left, rect.bottom-rect.top - 32, 0); width = (rect.right-rect.left); width/=NUMBUTTONS; for (i = 0; i < NUMBUTTONS; i++) @@ -1521,6 +1552,34 @@ static LONG CALLBACK MainWndProc(HWND hWnd,UINT message, GenericMenu(wParam); break; } + case WM_NOTIFY: + { + NMHDR *nm; + HANDLE item; + TVITEM i; + char filename[256]; + char itemtext[256]; + nm = lParam; + if (nm->hwndFrom == projecttree) + { + switch(nm->code) + { + case NM_CLICK: + item = TreeView_GetSelection(projecttree); + i.hItem = item; + i.mask = TVIF_TEXT; + i.pszText = itemtext; + i.cchTextMax = sizeof(itemtext)-1; + TreeView_GetItem(projecttree, &i); + while(i.hItem) + { + item = TreeView_GetParent(projecttree, item); + } + EditFile(filename, -1); + break; + } + } + } default: if (mdibox) return DefFrameProc(hWnd,mdibox,message,wParam,lParam); @@ -1771,6 +1830,92 @@ void CreateOutputWindow(void) SendMessage(mdibox, WM_MDIACTIVATE, (WPARAM)outputwindow, 0); } +//progssrcname should already have been set. +void SetProgsSrc(void) +{ + FILE *f; + + HANDLE rootitem, pi; + TVINSERTSTRUCT item; + TV_ITEM parent; + char parentstring[256]; + memset(&item, 0, sizeof(item)); + memset(&parent, 0, sizeof(parent)); + + if (projecttree) + { + int size; + char *buffer; + char *slash; + + f = fopen (progssrcname, "rb"); + if (!f) + return; + fseek(f, 0, SEEK_END); + size = ftell(f); + fseek(f, 0, SEEK_SET); + buffer = malloc(size+1); + if (!buffer) + { + fclose(f); + return; + } + buffer[size] = '\0'; + fread(buffer, 1, size, f); + fclose(f); + + pr_file_p = QCC_COM_Parse(buffer); + if (*qcc_token == '#') + { + free(buffer); //aaaahhh! newstyle! + return; + } + + pr_file_p = QCC_COM_Parse(pr_file_p); //we dont care about the produced progs.dat + + + item.hParent = TVI_ROOT; + item.hInsertAfter = TVI_SORT; + item.item.pszText = progssrcname; + item.item.mask = TVIF_TEXT; + rootitem = (HANDLE)SendMessage(projecttree,TVM_INSERTITEM,0,(LPARAM)&item); + while(pr_file_p) + { + pi = item.hParent = rootitem; + item.item.pszText = qcc_token; + while(slash = strchr(item.item.pszText, '/')) + { + *slash = '\0'; + item.hParent = TreeView_GetChild(projecttree, item.hParent); + do + { + parent.hItem = item.hParent; + parent.mask = TVIF_TEXT; + parent.pszText = parentstring; + parent.cchTextMax = sizeof(parentstring)-1; + if (TreeView_GetItem(projecttree, &parent)) + { + if (!stricmp(parent.pszText, item.item.pszText)) + break; + } + } while(item.hParent=TreeView_GetNextSibling(projecttree, item.hParent)); + if (!item.hParent) + { //add a directory. + item.hParent = pi; + pi = (HANDLE)SendMessage(projecttree,TVM_INSERTITEM,0,(LPARAM)&item); + } + else pi = item.hParent; + + item.item.pszText = slash+1; + } + SendMessage(projecttree,TVM_INSERTITEM,0,(LPARAM)&item); + pr_file_p = QCC_COM_Parse(pr_file_p); + } + + free(buffer); + } +} + int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { unsigned int i; @@ -1863,6 +2008,8 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin } } + resetprogssrc = true; + wndclass.style = 0; wndclass.lpfnWndProc = (WNDPROC)MainWndProc; wndclass.cbClsExtra = 0; @@ -1948,6 +2095,12 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin { MSG msg; + if (resetprogssrc) + { //this here, with the compiler below, means that we don't run recursivly. + resetprogssrc = false; + SetProgsSrc(); + } + EditorsRun(); while (PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE)) diff --git a/engine/qclib/qccmain.c b/engine/qclib/qccmain.c index a42cebbb2..f4ea3b637 100644 --- a/engine/qclib/qccmain.c +++ b/engine/qclib/qccmain.c @@ -178,26 +178,35 @@ optimisations_t optimisations[] = compiler_flag_t compiler_flag[] = { //keywords - {&keyword_var, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "var", "Keyword: var", "Disables the 'var' keyword."}, - {&keyword_thinktime, FLAG_HIDDENINGUI|0, "thinktime", "Keyword: thinktime", "Disables the 'thinktime' keyword."}, - {&keyword_switch, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "switch", "Keyword: switch", "Disables the 'switch' keyword."}, - {&keyword_for, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "for", "Keyword: for", "Disables the 'for' keyword."}, - {&keyword_case, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "case", "Keyword: case", "Disables the 'case' keyword."}, - {&keyword_default, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "default", "Keyword: default", "Disables the 'default' keyword."}, - {&keyword_do, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "do", "Keyword: do", "Disables the 'do' keyword."}, - {&keyword_asm, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "asm", "Keyword: asm", "Disables the 'asm' keyword."}, - {&keyword_goto, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "goto", "Keyword: goto", "Disables the 'goto' keyword."}, - {&keyword_break, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "break", "Keyword: break", "Disables the 'break' keyword."}, + {&keyword_asm, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "asm", "Keyword: asm", "Disables the 'asm' keyword."}, + {&keyword_break, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "break", "Keyword: break", "Disables the 'break' keyword."}, + {&keyword_case, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "case", "Keyword: case", "Disables the 'case' keyword."}, + {&keyword_class, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "class", "Keyword: class", "Disables the 'class' keyword."}, + {&keyword_const, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "const", "Keyword: const", "Disables the 'const' keyword."}, {&keyword_continue, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "continue", "Keyword: continue", "Disables the 'continue' keyword."}, - {&keyword_state, FLAG_HIDDENINGUI|0, "state", "Keyword: state", "Disables the 'state' keyword."}, - {&keyword_string, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "string", "Keyword: string", "Disables the 'string' keyword."}, - {&keyword_float, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "float", "Keyword: float", "Disables the 'float' keyword."}, - {&keyword_entity, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "entity", "Keyword: entity", "Disables the 'entity' keyword."}, - {&keyword_vector, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "vector", "Keyword: vector", "Disables the 'vector' keyword."}, - {&keyword_const, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "const", "Keyword: const", "Disables the 'const' keyword."}, - {&keyword_integer, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "integer", "Keyword: integer", "Disables the 'integer' keyword."}, - {&keyword_int, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "int", "Keyword: int", "Disables the 'int' keyword."}, - {&keyword_class, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "class", "Keyword: class", "Disables the 'class' keyword."}, + {&keyword_default, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "default", "Keyword: default", "Disables the 'default' keyword."}, + {&keyword_entity, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "entity", "Keyword: entity", "Disables the 'entity' keyword."}, + {&keyword_enum, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "enum", "Keyword: enum", "Disables the 'enum' keyword."}, //kinda like in c, but typedef not supported. + {&keyword_enumflags, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "enumflags", "Keyword: enumflags", "Disables the 'enumflags' keyword."}, //like enum, but doubles instead of adds 1. + {&keyword_extern, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "extern", "Keyword: extern", "Disables the 'extern' keyword."}, //function is external, don't error or warn if the body was not found + {&keyword_float, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "float", "Keyword: float", "Disables the 'float' keyword."}, + {&keyword_for, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "for", "Keyword: for", "Disables the 'for' keyword."}, + {&keyword_goto, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "goto", "Keyword: goto", "Disables the 'goto' keyword."}, + {&keyword_int, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "int", "Keyword: int", "Disables the 'int' keyword."}, + {&keyword_integer, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "integer", "Keyword: integer", "Disables the 'integer' keyword."}, + {&keyword_noref, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "noref", "Keyword: noref", "Disables the 'noref' keyword."}, //nowhere else references this, don't strip it. + {&keyword_nosave, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "nosave", "Keyword: nosave", "Disables the 'nosave' keyword."}, //don't write the def to the output. + {&keyword_shared, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "shared", "Keyword: shared", "Disables the 'shared' keyword."}, //mark global to be copied over when progs changes (part of FTE_MULTIPROGS) + {&keyword_state, FLAG_HIDDENINGUI|0, "state", "Keyword: state", "Disables the 'state' keyword."}, + {&keyword_string, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "string", "Keyword: string", "Disables the 'string' keyword."}, + {&keyword_struct, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "struct", "Keyword: struct", "Disables the 'struct' keyword."}, + {&keyword_switch, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "switch", "Keyword: switch", "Disables the 'switch' keyword."}, + {&keyword_thinktime, FLAG_HIDDENINGUI|0, "thinktime", "Keyword: thinktime", "Disables the 'thinktime' keyword."}, + {&keyword_typedef, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "typedef", "Keyword: typedef", "Disables the 'typedef' keyword."}, //fixme + {&keyword_union, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "union", "Keyword: union", "Disables the 'union' keyword."}, //you surly know what a union is! + {&keyword_var, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "var", "Keyword: var", "Disables the 'var' keyword."}, + {&keyword_vector, FLAG_HIDDENINGUI|FLAG_ASDEFAULT, "vector", "Keyword: vector", "Disables the 'vector' keyword."}, + //options {&keywords_coexist, FLAG_ASDEFAULT, "kce", "Keywords Coexist", "If you want keywords to NOT be disabled when they a variable by the same name is defined, check here."}, @@ -2479,7 +2488,7 @@ void QCC_SetDefaultProperties (void) QCC_PR_CommandLinePrecompilerOptions(); - if (qcc_targetformat == QCF_HEXEN2) + if (qcc_targetformat == QCF_HEXEN2) //force on the thinktime keyword if hexen2 progs. keyword_thinktime = true; if (QCC_CheckParm("/Debug")) //disable any debug optimisations @@ -2830,13 +2839,6 @@ memset(pr_immediate_string, 0, sizeof(pr_immediate_string)); } } - newstylesource = false; - - while(*qccmsrc && *qccmsrc < ' ') - qccmsrc++; - - pr_file_p = QCC_COM_Parse(qccmsrc); - #ifdef WRITEASM if (writeasm) { @@ -2846,6 +2848,11 @@ memset(pr_immediate_string, 0, sizeof(pr_immediate_string)); } #endif + newstylesource = false; + while(*qccmsrc && *qccmsrc < ' ') + qccmsrc++; + pr_file_p = QCC_COM_Parse(qccmsrc); + if (QCC_CheckParm ("-qc")) { strcpy(destfile, qccmprogsdat); diff --git a/engine/server/pr_cmds.c b/engine/server/pr_cmds.c index d5af21631..048975650 100644 --- a/engine/server/pr_cmds.c +++ b/engine/server/pr_cmds.c @@ -7857,7 +7857,7 @@ void PF_runclientphys(progfuncs_t *prinst, struct globalvars_s *pr_globals) // AddLinksToPmove ( sv_areanodes ); - PM_PlayerMove(); + PM_PlayerMove(sv.gamespeed); } BuiltinList_t BuiltinList[] = { //nq qw h2 ebfs diff --git a/engine/server/server.h b/engine/server/server.h index 524ab559b..df38fb281 100644 --- a/engine/server/server.h +++ b/engine/server/server.h @@ -102,6 +102,9 @@ typedef struct qboolean active; // false when server is going down server_state_t state; // precache commands are only valid during load + float gamespeed; //time progression multiplier, fixed per-level. + qboolean csqcdebug; + double time; int framenum; @@ -118,14 +121,22 @@ typedef struct char mapname[256]; char modelname[MAX_QPATH]; // maps/.bsp, for model_precache[0] struct model_s *worldmodel; - char model_precache[MAX_MODELS][MAX_QPATH]; // NULL terminated - char sound_precache[MAX_SOUNDS][MAX_QPATH]; // NULL terminated - char image_precache[Q2MAX_IMAGES][MAX_QPATH]; - char *lightstyles[MAX_LIGHTSTYLES]; - char lightstylecolours[MAX_LIGHTSTYLES]; - struct model_s *models[MAX_MODELS]; - char *statusbar; //part of the config strings - q2 has a progs specified sbar. + union { +#ifdef Q2SERVER + struct { + char configstring[Q2MAX_CONFIGSTRINGS][MAX_QPATH]; + }; +#endif + struct { + char model_precache[MAX_MODELS][MAX_QPATH]; // NULL terminated + char sound_precache[MAX_SOUNDS][MAX_QPATH]; // NULL terminated + char image_precache[Q2MAX_IMAGES][MAX_QPATH]; + char *lightstyles[MAX_LIGHTSTYLES]; + char lightstylecolours[MAX_LIGHTSTYLES]; + }; + }; + struct model_s *models[MAX_MODELS]; int allocated_client_slots; //number of slots available. (used mostly to stop single player saved games cacking up) int max_edicts; //limiting factor... 1024 fields*4*MAX_EDICTS == a heck of a lot. diff --git a/engine/server/sv_ents.c b/engine/server/sv_ents.c index 9663c112d..0e8d1b7bb 100644 --- a/engine/server/sv_ents.c +++ b/engine/server/sv_ents.c @@ -347,6 +347,12 @@ void SV_EmitCSQCUpdate(client_t *client, sizebuf_t *msg) MSG_WriteByte(msg, svc_csqcentities); } MSG_WriteShort(msg, ent->entnum); + if (sv.csqcdebug) //optional extra. + { + if (!csqcmsgbuffer.cursize) + Con_Printf("Warning: empty csqc packet on %s\n", svprogfuncs->stringtable+ent->v.classname); + MSG_WriteShort(msg, csqcmsgbuffer.cursize); + } //FIXME: Add a developer mode to write the length of each entity. SZ_Write(msg, csqcmsgbuffer.data, csqcmsgbuffer.cursize); @@ -2141,6 +2147,7 @@ void SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg, qboolean ignore if (!ignorepvs) { + //branch out to the pvs testing. if (ent->tagent) { edict_t *p = ent; @@ -2157,54 +2164,6 @@ void SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg, qboolean ignore if (!sv.worldmodel->funcs.EdictInFatPVS(ent)) continue; } - /* -#ifdef Q2BSPS - if (sv.worldmodel->fromgame == fg_quake2 || sv.worldmodel->fromgame == fg_quake3) - {//quake2 vising logic - // check area - if (!CM_AreasConnected (clientarea, ent->areanum)) - { // doors can legally straddle two areas, so - // we may need to check another one - if (!ent->areanum2 - || !CM_AreasConnected (clientarea, ent->areanum2)) - continue; // blocked by a door - } - - if (ent->num_leafs == -1) - { // too many leafs for individual check, go by headnode - if (!CM_HeadnodeVisible (ent->headnode, fatpvs)) - continue; - } - else - { // check individual leafs - for (i=0 ; i < ent->num_leafs ; i++) - { - l = ent->leafnums[i]; - if (fatpvs[l >> 3] & (1 << (l&7) )) - break; - } - if (i == ent->num_leafs) - continue; // not visible - } - } - else -#endif - if (sv.worldmodel->fromgame == fg_doom) - { - } - else - {//quake1 vising logic - // ignore if not touching a PV leaf - for (i=0 ; i < ent->num_leafs ; i++) - if (pvs[ent->leafnums[i] >> 3] & (1 << (ent->leafnums[i]&7) )) - break; - - if (i == ent->num_leafs) // not visible - { - continue; - } - } - */ } diff --git a/engine/server/sv_init.c b/engine/server/sv_init.c index bfaf692f0..2dca25cf8 100644 --- a/engine/server/sv_init.c +++ b/engine/server/sv_init.c @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern int total_loading_size, current_loading_size, loading_stage; char *T_GetString(int num); -#define Q2EDICT_NUM(i) (q2edict_t*)((char *)ge->edicts+i*ge->edict_size) +#define Q2EDICT_NUM(i) (q2edict_t*)((char *)ge->edicts+(i)*ge->edict_size) server_static_t svs; // persistant server info server_t sv; // local server @@ -35,6 +35,8 @@ char localinfo[MAX_LOCALINFO_STRING+1]; // local game info extern cvar_t skill, sv_loadentfiles; extern cvar_t sv_cheats; extern cvar_t sv_bigcoords; +extern cvar_t sv_gamespeed; +extern cvar_t sv_csqcdebug; extern qboolean sv_allow_cheats; /* @@ -671,21 +673,6 @@ void SV_SpawnServer (char *server, char *startspot, qboolean noents, qboolean us // SV_ClearWorld (); - strcpy(sv.sound_precache[0], ""); - strcpy(sv.model_precache[0], ""); - - strcpy(sv.model_precache[1], sv.modelname); - sv.models[1] = sv.worldmodel; - for (i=1 ; inumsubmodels ; i++) - { - strcpy(sv.model_precache[1+i], localmodels[i]); - sv.models[i+1] = Mod_ForName (localmodels[i], false); - } - - //check player/eyes models for hacks - sv.model_player_checksum = SV_CheckModel("progs/player.mdl"); - sv.eyes_player_checksum = SV_CheckModel("progs/eyes.mdl"); - if (sv_cheats.value) { sv_allow_cheats = true; @@ -697,6 +684,15 @@ void SV_SpawnServer (char *server, char *startspot, qboolean noents, qboolean us Info_SetValueForStarKey(svs.info, "*cheats", "", MAX_SERVERINFO_STRING); } + sv.gamespeed = sv_gamespeed.value; + Info_SetValueForStarKey(svs.info, "*gamespeed", va("%i", (int)(sv.gamespeed*100)), MAX_SERVERINFO_STRING); + sv.gamespeed = atof(Info_ValueForKey(svs.info, "*gamespeed"))/100; + if (sv.gamespeed < 0.1 || sv.gamespeed == 1) + { + sv.gamespeed = 1; + Info_SetValueForStarKey(svs.info, "*gamespeed", "", MAX_SERVERINFO_STRING); + } + //do we allow csprogs? #ifdef PEXT_CSQC file = COM_LoadTempFile("csprogs.dat"); @@ -708,7 +704,18 @@ void SV_SpawnServer (char *server, char *startspot, qboolean noents, qboolean us } else Info_SetValueForStarKey(svs.info, "*csprogs", "", MAX_SERVERINFO_STRING); + + sv.csqcdebug = sv_csqcdebug.value; + if (sv.csqcdebug) + Info_SetValueForStarKey(svs.info, "*csqcdebug", "1", MAX_SERVERINFO_STRING); + else + Info_RemoveKey(svs.info, "*csqcdebug"); #endif + + + + + if (svprogfuncs) //we don't want the q1 stuff anymore. { CloseProgs(svprogfuncs); @@ -755,6 +762,36 @@ void SV_SpawnServer (char *server, char *startspot, qboolean noents, qboolean us } } + sv.models[1] = sv.worldmodel; + if (svs.gametype == GT_PROGS) + { + strcpy(sv.sound_precache[0], ""); + strcpy(sv.model_precache[0], ""); + + strcpy(sv.model_precache[1], sv.modelname); + for (i=1 ; inumsubmodels ; i++) + { + strcpy(sv.model_precache[1+i], localmodels[i]); + sv.models[i+1] = Mod_ForName (localmodels[i], false); + } + + //check player/eyes models for hacks + sv.model_player_checksum = SV_CheckModel("progs/player.mdl"); + sv.eyes_player_checksum = SV_CheckModel("progs/eyes.mdl"); + } + else if (svs.gametype == GT_QUAKE2) + { + memset(sv.configstring, 0, sizeof(sv.configstring)); + strcpy(sv.configstring[Q2CS_MODELS+1], sv.modelname); + for (i=1; inumsubmodels; i++) + { + strcpy(sv.configstring[Q2CS_MODELS+1+i], localmodels[i]); + sv.models[i+1] = Mod_ForName (localmodels[i], false); + } + } + + + #ifndef SERVERONLY current_loading_size+=10; SCR_BeginLoadingPlaque(); diff --git a/engine/server/sv_main.c b/engine/server/sv_main.c index b6002ae65..6e190ff0e 100644 --- a/engine/server/sv_main.c +++ b/engine/server/sv_main.c @@ -93,6 +93,8 @@ cvar_t sv_master = {"sv_master", "0"}; cvar_t sv_masterport = {"sv_masterport", "0"}; cvar_t sv_voicechat = {"sv_voicechat", "0"}; //still development. +cvar_t sv_gamespeed = {"sv_gamespeed", "1"}; +cvar_t sv_csqcdebug = {"sv_csqcdebug", "0"}; cvar_t pausable = {"pausable", "1"}; @@ -331,7 +333,10 @@ void SV_DropClient (client_t *drop) #ifdef SVCHAT SV_WipeChat(drop); #endif - +#ifdef Q2SERVER + if (ge) + ge->ClientDisconnect(drop->q2edict); +#endif if (svprogfuncs) { if (drop->state == cs_spawned) @@ -356,10 +361,6 @@ void SV_DropClient (client_t *drop) Z_Free(drop->spawninfo); drop->spawninfo = NULL; } -#ifdef Q2SERVER - else if (ge && drop->q2edict) //could be in sv_spawnserver. - ge->ClientDisconnect(drop->q2edict); -#endif if (drop->spectator) Con_Printf ("Spectator %s removed\n",drop->name); @@ -1472,7 +1473,7 @@ void SVC_DirectConnect if (!ge->ClientConnect(q2ent, temp.userinfo)) return; - + ge->ClientUserinfoChanged(q2ent, temp.userinfo); // build a new connection // accept the new client @@ -2615,7 +2616,7 @@ void SV_GetConsoleCommands (void) int SV_RateForClient(client_t *cl) { int rate; - if (cl->download) + if (cl->download && cl->drate) { rate = cl->drate; if (rate > sv_maxdrate.value) @@ -2755,12 +2756,17 @@ void SV_Frame (float time) // keep the random time dependent rand (); + if (!sv.gamespeed) + sv.gamespeed = 1; + // decide the simulation time if (!sv.paused) { #ifndef SERVERONLY if (isDedicated) #endif realtime += time; + + time *= sv.gamespeed; sv.time += time; } #ifdef IWEB_H__ @@ -3006,6 +3012,9 @@ void SV_InitLocal (void) Cvar_Register (&sv_phs, cvargroup_servercontrol); + Cvar_Register (&sv_csqcdebug, cvargroup_servercontrol); + + Cvar_Register (&sv_gamespeed, cvargroup_serverphysics); Cvar_Register (&sv_nomsec, cvargroup_serverphysics); Cvar_Register (&pr_allowbutton1, cvargroup_servercontrol); @@ -3414,7 +3423,7 @@ void SV_ExtractFromUserinfo (client_t *cl) if (strlen(val)) cl->drate = atoi(val); else - cl->drate = cl->rate; + cl->drate = 0; //0 disables the downloading check // msg command val = Info_ValueForKey (cl->userinfo, "msg"); diff --git a/engine/server/sv_user.c b/engine/server/sv_user.c index 34fa431f1..be69c8390 100644 --- a/engine/server/sv_user.c +++ b/engine/server/sv_user.c @@ -325,6 +325,7 @@ void SVQ2_ConfigStrings_f (void) { extern int map_checksum; int start; + char *str; Con_DPrintf ("Configstrings() from %s\n", host_client->name); @@ -356,18 +357,21 @@ void SVQ2_ConfigStrings_f (void) while ( host_client->netchan.message.cursize < MAX_QWMSGLEN/2 && start < Q2MAX_CONFIGSTRINGS) { - + str = sv.configstring[start]; + if (*str) + { + MSG_WriteByte (&host_client->netchan.message, svcq2_configstring); + MSG_WriteShort (&host_client->netchan.message, start); + MSG_WriteString (&host_client->netchan.message, str); + } + /* //choose range to grab from. if (start < Q2CS_CDTRACK) { MSG_WriteByte (&host_client->netchan.message, svcq2_configstring); MSG_WriteShort (&host_client->netchan.message, start); MSG_WriteString (&host_client->netchan.message, sv.name); -/* if (svprogfuncs) - MSG_WriteString (&host_client->netchan.message, va("%s", PR_GetString(svprogfuncs, sv.edicts->v.message))); - else - MSG_WriteString (&host_client->netchan.message, "LEVEL NAME"); -*/ } + } else if (start < Q2CS_SKY) { MSG_WriteByte (&host_client->netchan.message, svcq2_configstring); @@ -476,6 +480,7 @@ void SVQ2_ConfigStrings_f (void) // MSG_WriteShort (&host_client->netchan.message, start); // MSG_WriteString (&host_client->netchan.message, sv.configstrings[start]); } + */ start++; } @@ -2137,25 +2142,16 @@ Change the bandwidth estimate for a client ================= */ void SV_Rate_f (void) -{ - extern cvar_t sv_maxrate; - int rate; - +{ if (Cmd_Argc() != 2) { - SV_ClientTPrintf (host_client, PRINT_HIGH, STL_CURRENTRATE, - host_client->rate); + SV_ClientPrintf (host_client, PRINT_HIGH, "Effective rate %i\n", SV_RateForClient(host_client)); return; } - - rate = atoi(Cmd_Argv(1)); - if (rate < 500) - rate = 500; - if (rate > sv_maxrate.value) - rate = sv_maxrate.value; - SV_ClientTPrintf (host_client, PRINT_HIGH, STL_RATESETTO, rate); - host_client->rate = rate; + host_client->rate = atoi(Cmd_Argv(1)); + + SV_ClientTPrintf (host_client, PRINT_HIGH, STL_RATESETTO, SV_RateForClient(host_client)); } @@ -2854,9 +2850,10 @@ ucmd_t ucmdsq2[] = { {"baselines", SVQ2_BaseLines_f, true}, {"begin", SV_Begin_f, true}, - {"setinfo", SV_SetInfo_f, true}, +// {"setinfo", SV_SetInfo_f, true}, {"serverinfo", SV_ShowServerinfo_f, true}, + {"info", SV_ShowServerinfo_f, true}, {"download", SV_BeginDownload_f, true}, {"nextdl", SV_NextDownload_f, true}, @@ -2865,9 +2862,9 @@ ucmd_t ucmdsq2[] = { {"vote", SV_Vote_f, true}, -#ifdef SVRANKING - {"topten", Rank_ListTop10_f, true}, -#endif +//#ifdef SVRANKING +// {"topten", Rank_ListTop10_f, true}, +//#endif {"drop", SV_Drop_f, true}, {"disconnect", SV_Drop_f, true}, @@ -3754,6 +3751,7 @@ void SV_RunCmd (usercmd_t *ucmd, qboolean recurse) } host_frametime = ucmd->msec * 0.001; + host_frametime *= sv.gamespeed; if (host_frametime > 0.1) host_frametime = 0.1; @@ -3800,7 +3798,7 @@ void SV_RunCmd (usercmd_t *ucmd, qboolean recurse) pmove_maxs[i] = pmove.origin[i] + 256; } - PM_PlayerMove (); + PM_PlayerMove (cl.gamespeed); VectorCopy (pmove.origin, host_client->specorigin); VectorCopy (pmove.velocity, host_client->specvelocity); @@ -3978,7 +3976,7 @@ if (sv_player->v.health > 0 && before && !after ) Con_Printf ("player %s got stuck in playermove!!!!\n", host_client->name); } #else - PM_PlayerMove (); + PM_PlayerMove (sv.gamespeed); #endif host_client->jump_held = pmove.jump_held; @@ -4496,7 +4494,9 @@ void SVQ2_ExecuteClientMessage (client_t *cl) break; case clcq2_userinfo: - s = MSG_ReadString (); + strncpy (cl->userinfo, MSG_ReadString (), sizeof(cl->userinfo)-1); + ge->ClientUserinfoChanged (cl->q2edict, cl->userinfo); //tell the gamecode + SV_ExtractFromUserinfo(cl); //let the server routines know break; case clcq2_stringcmd: diff --git a/engine/server/svq2_game.c b/engine/server/svq2_game.c index fded2dd16..e7155d96f 100644 --- a/engine/server/svq2_game.c +++ b/engine/server/svq2_game.c @@ -176,6 +176,12 @@ static void VARGS PFQ2_Configstring (int i, char *val) if (!val) val = ""; + strcpy(sv.configstring[i], val); + + if (i == Q2CS_NAME) + Q_strncpyz(sv.mapname, val, sizeof(sv.name)); + +/* //work out range if (i >= Q2CS_LIGHTS && i < Q2CS_LIGHTS+Q2MAX_LIGHTSTYLES) { @@ -213,32 +219,10 @@ static void VARGS PFQ2_Configstring (int i, char *val) } else { -/* -#define Q2CS_NAME 0 -#define Q2CS_CDTRACK 1 -#define Q2CS_SKY 2 -#define Q2CS_SKYAXIS 3 // %f %f %f format -#define Q2CS_SKYROTATE 4 -#define Q2CS_STATUSBAR 5 // display program string - -#define Q2CS_AIRACCEL 29 // air acceleration control -#define Q2CS_MAXCLIENTS 30 -#define Q2CS_MAPCHECKSUM 31 // for catching cheater maps - -#define Q2CS_MODELS 32 -#define Q2CS_SOUNDS (Q2CS_MODELS +Q2MAX_MODELS) -#define Q2CS_IMAGES (Q2CS_SOUNDS +Q2MAX_SOUNDS) -#define Q2CS_LIGHTS (Q2CS_IMAGES +Q2MAX_IMAGES) -#define Q2CS_ITEMS (Q2CS_LIGHTS +Q2MAX_LIGHTSTYLES) -#define Q2CS_PLAYERSKINS (Q2CS_ITEMS +Q2MAX_ITEMS) -#define Q2CS_GENERAL (Q2CS_PLAYERSKINS +Q2MAX_CLIENTS) -*/ - - Con_Printf("Ignoring configstring %i\n", i); } +*/ - if (sv.state != ss_loading) { // send the update to everyone SZ_Clear (&sv.multicast); @@ -250,9 +234,12 @@ static void VARGS PFQ2_Configstring (int i, char *val) } } -static int SVQ2_FindIndex (char *name, int start, int max, char *strings, int stringlength, qboolean create) +static int SVQ2_FindIndex (char *name, int start, int max, qboolean create) { int i; + int stringlength = MAX_QPATH; + char *strings = sv.configstring[start]; + strings += stringlength; if (!name || !name[0]) return 0; @@ -275,17 +262,17 @@ static int SVQ2_FindIndex (char *name, int start, int max, char *strings, int st static int VARGS SVQ2_ModelIndex (char *name) { - return SVQ2_FindIndex (name, Q2CS_MODELS, Q2MAX_MODELS, sv.model_precache[1], sizeof(sv.model_precache[0]), true); + return SVQ2_FindIndex (name, Q2CS_MODELS, Q2MAX_MODELS, true); } static int VARGS SVQ2_SoundIndex (char *name) { - return SVQ2_FindIndex (name, Q2CS_SOUNDS, Q2MAX_SOUNDS, sv.sound_precache[1], sizeof(sv.sound_precache[0]), true); + return SVQ2_FindIndex (name, Q2CS_SOUNDS, Q2MAX_SOUNDS, true); } static int VARGS SVQ2_ImageIndex (char *name) { - return SVQ2_FindIndex (name, Q2CS_IMAGES, Q2MAX_IMAGES, sv.image_precache[1], sizeof(sv.image_precache[0]), true); + return SVQ2_FindIndex (name, Q2CS_IMAGES, Q2MAX_IMAGES, true); } /*