From 7030c239942e308c33db79e4e7c031b933ae6ea7 Mon Sep 17 00:00:00 2001 From: L Date: Sun, 7 May 2023 20:38:08 +0200 Subject: [PATCH] Fixed compilation issues --- code/cgame/cg_commands.cpp | 2 +- code/cgame/cg_drawtools.cpp | 8 +- code/cgame/cg_lightstyles.cpp | 2 +- code/cgame/cg_public.h | 58 +- code/cgame/cg_servercmds.c | 8 +- code/client/cl_cgame.cpp | 96 ++- code/client/cl_console.cpp | 789 -------------------- code/client/cl_consolecmds.cpp | 2 +- code/client/cl_main.cpp | 6 +- code/client/cl_parse.cpp | 13 +- code/client/cl_ui.c | 1212 ------------------------------- code/client/cl_ui.cpp | 8 +- code/client/cl_ui.h | 2 +- code/client/cl_uiview3d.cpp | 1 - code/client/snd_dma_new.cpp | 22 +- code/client/snd_mix.c | 2 +- code/null/null_input.c | 2 +- code/qcommon/cmd.c | 2 +- code/qcommon/files.cpp | 4 +- code/qcommon/msg.cpp | 2 +- code/qcommon/qcommon.h | 8 +- code/qcommon/script.cpp | 2 +- code/renderercommon/tr_public.h | 18 +- code/uilib/uimenu.h | 3 + 24 files changed, 137 insertions(+), 2135 deletions(-) delete mode 100644 code/client/cl_console.cpp delete mode 100644 code/client/cl_ui.c diff --git a/code/cgame/cg_commands.cpp b/code/cgame/cg_commands.cpp index 324850ab..0df1f57a 100644 --- a/code/cgame/cg_commands.cpp +++ b/code/cgame/cg_commands.cpp @@ -6240,7 +6240,7 @@ qboolean CG_Command_ProcessFile(const char* filename, qboolean quiet, dtiki_t *c const char* bufstart; char com_token[MAX_STRING_CHARS]; - if (cgi.FS_ReadFile(filename, (void**)&buffer) == -1) { + if (cgi.FS_ReadFile(filename, (void**)&buffer, quiet) == -1) { return qfalse; } diff --git a/code/cgame/cg_drawtools.cpp b/code/cgame/cg_drawtools.cpp index 9ae1cbd0..9be76363 100644 --- a/code/cgame/cg_drawtools.cpp +++ b/code/cgame/cg_drawtools.cpp @@ -982,9 +982,9 @@ void CG_DrawStopwatch() { int iFraction; - if (!cg_hud->integer || !cgi.stopWatch->startTime - || cgi.stopWatch->startTime >= cgi.stopWatch->endTime - || cgi.stopWatch->endTime <= cg.time + if (!cg_hud->integer || !cgi.stopWatch->iStartTime + || cgi.stopWatch->iStartTime >= cgi.stopWatch->iEndTime + || cgi.stopWatch->iEndTime <= cg.time // don't draw the stopwatch with the objective menu || cg.ObjectivesCurrentAlpha >= 0.02 // the player isn't alive @@ -994,7 +994,7 @@ void CG_DrawStopwatch() return; } - iFraction = cgi.stopWatch->endTime - cg.time; + iFraction = cgi.stopWatch->iEndTime - cg.time; cgi.Cvar_Set("ui_stopwatch", va("%i", iFraction)); cgi.Cmd_Execute(EXEC_NOW, "ui_addhud hud_stopwatch\n"); } diff --git a/code/cgame/cg_lightstyles.cpp b/code/cgame/cg_lightstyles.cpp index d34895c9..05adfe46 100644 --- a/code/cgame/cg_lightstyles.cpp +++ b/code/cgame/cg_lightstyles.cpp @@ -134,7 +134,7 @@ static qboolean LoadTGA(const char * name, byte ** pic, int *width, int *height, // // load the file // - cgi.FS_ReadFile(name, (void **)&buffer); + cgi.FS_ReadFile(name, (void **)&buffer, qtrue); if (!buffer) { cgi.DPrintf( "TGA File not found: %s\n", name ); diff --git a/code/cgame/cg_public.h b/code/cgame/cg_public.h index 1232e15c..40d4a41c 100644 --- a/code/cgame/cg_public.h +++ b/code/cgame/cg_public.h @@ -68,8 +68,8 @@ typedef struct { typedef struct stopWatch_s { - int startTime; - int endTime; + int iStartTime; + int iEndTime; } stopWatch_t; @@ -136,9 +136,9 @@ typedef struct // a -1 return means the file does not exist // NULL can be passed for buf to just determine existance - int (*FS_ReadFile)( const char *name, void **buf ); + int (*FS_ReadFile)( const char *name, void **buf, qboolean quiet ); void (*FS_FreeFile)( void *buf ); - void (*FS_WriteFile)( const char *qpath, const void *buffer, int size ); + int (*FS_WriteFile)( const char *qpath, const void *buffer, int size ); void (*FS_WriteTextFile)( const char *qpath, const void *buffer, int size ); // add commands to the local console as if they were typed in // for map changing, etc. The command is not executed immediately, @@ -170,7 +170,7 @@ typedef struct clipHandle_t (*CM_InlineModel)( int index ); // 0 = world, 1+ = bmodels int (*CM_NumInlineModels)( void ); int (*CM_PointContents)( const vec3_t p, int headnode ); - int (*CM_TransformedPointContents)( const vec3_t p, int headnode, vec3_t origin, vec3_t angles ); + int (*CM_TransformedPointContents)(const vec3_t p, clipHandle_t model, const vec3_t origin, const vec3_t angles); void (*CM_BoxTrace)( trace_t *results, const vec3_t start, const vec3_t end, const vec3_t mins, const vec3_t maxs, int headnode, int brushmask, qboolean cylinder ); @@ -183,7 +183,7 @@ typedef struct clipHandle_t (*CM_TempBoxModel)( const vec3_t mins, const vec3_t maxs, int contents ); void (*CM_PrintBSPFileSizes)(); qboolean (*CM_LeafInPVS)(int leaf1, int leaf2); - int (*CM_PointLeafnum)(vec3_t p); + int (*CM_PointLeafnum)(const vec3_t p); int (*R_MarkFragments)( int numPoints, const vec3_t *points, const vec3_t projection, int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer, float fRadiusSquared ); @@ -199,12 +199,12 @@ typedef struct // =========== sound function calls =============== - void (*S_StartSound)(vec3_t origin, int entNum, int entChannel, sfxHandle_t sfxHandle, float volume, float minDist, float pitch, float maxDist, int streamed); - void (*S_StartLocalSound)(char* soundName, qboolean forceLoad); + void (*S_StartSound)(const vec3_t origin, int entNum, int entChannel, sfxHandle_t sfxHandle, float volume, float minDist, float pitch, float maxDist, int streamed); + void (*S_StartLocalSound)(const char* soundName, qboolean forceLoad); void (*S_StopSound)( int entnum, int channel ); void (*S_ClearLoopingSounds)(void); - void (*S_AddLoopingSound)(vec3_t origin, vec3_t velocity, sfxHandle_t sfxHandle, float volume, float minDist, float maxDist, float pitch, int flags); - void (*S_Respatialize)( int entityNum, vec3_t origin, vec3_t axis[3] ); + void (*S_AddLoopingSound)(const vec3_t origin, const vec3_t velocity, sfxHandle_t sfxHandle, float volume, float minDist, float maxDist, float pitch, int flags); + void (*S_Respatialize)( int entityNum, const vec3_t origin, vec3_t axis[3] ); void (*S_BeginRegistration)( void ); sfxHandle_t (*S_RegisterSound)( const char *sample, int streamed ); void (*S_EndRegistration)( void ); @@ -212,9 +212,9 @@ typedef struct void (*S_SetReverb)( int reverb_type, float reverb_level ); void (*S_SetGlobalAmbientVolumeLevel)( float volume ); float (*S_GetSoundTime)(sfxHandle_t handle); - int (*S_ChannelNameToNum)(char* name); - char* (*S_ChannelNumToName)(int channel); - int (*S_IsSoundPlaying)(int channelNumber, char* name); + int (*S_ChannelNameToNum)(const char* name); + const char* (*S_ChannelNumToName)(int channel); + int (*S_IsSoundPlaying)(int channelNumber, const char* name); // =========== music function calls =============== @@ -240,10 +240,10 @@ typedef struct qhandle_t (*R_RegisterSkin)( const char *name ); qhandle_t (*R_RegisterShader)( const char *name ); qhandle_t (*R_RegisterShaderNoMip)( const char *name ); - void (*R_AddRefEntityToScene)( refEntity_t *ent, int parentEntityNumber ); - void (*R_AddRefSpriteToScene)( refEntity_t *ent ); - void (*R_AddLightToScene)( vec3_t origin, float intensity, float r, float g, float b, int type ); - void (*R_AddPolyToScene)(qhandle_t hShader, int numVerts, const polyVert_t* verts, int renderfx); + void (*R_AddRefEntityToScene)(const refEntity_t *ent, int parentEntityNumber ); + void (*R_AddRefSpriteToScene)(const refEntity_t *ent ); + void (*R_AddLightToScene)(const vec3_t origin, float intensity, float r, float g, float b, int type ); + qboolean (*R_AddPolyToScene)(qhandle_t hShader, int numVerts, const polyVert_t* verts, int renderfx); void (*R_AddTerrainMarkToScene)(int terrainIndex, qhandle_t hShader, int numVerts, polyVert_t* verts, int renderFx); void (*R_SetColor)( const vec4_t rgba ); // NULL = 1,1,1,1 void (*R_DrawStretchPic) ( float x, float y, float w, float h, @@ -279,34 +279,34 @@ typedef struct // which is the local predicted command for // the following frame qboolean (*GetUserCmd)( int cmdNumber, usercmd_t *ucmd ); - qboolean (*GetServerCommand)( int serverCommandNumber ); + qboolean (*GetServerCommand)(int serverCommandNumber, qboolean differentServer); // ALIAS STUFF qboolean (*Alias_Add)( const char * alias, const char * name, const char *parameters ); qboolean (*Alias_ListAdd)(AliasList_t* list, const char* alias, const char* name, const char* parameters); const char* (*Alias_FindRandom)(const char* alias, AliasListNode_t **ret); - char* (*Alias_ListFindRandom)(AliasList_t* list, const char* alias, AliasListNode_t** ret); + const char* (*Alias_ListFindRandom)(AliasList_t* list, const char* alias, AliasListNode_t** ret); void (*Alias_Dump)( void ); void (*Alias_Clear)( void ); - AliasList_t* (*AliasList_New)(char* name); + AliasList_t* (*AliasList_New)(const char* name); void (*Alias_ListFindRandomRange)(AliasList_t* list, const char* alias, int* minIndex, int* maxIndex, float* totalWeight); AliasList_t* (*Alias_GetGlobalList)(); // ==================== UI STUFF ========================== - void (*UI_ShowMenu)(char* name, qboolean bForce); - void (*UI_HideMenu)(char* name, qboolean bForce); + void (*UI_ShowMenu)(const char* name, qboolean bForce); + void (*UI_HideMenu)(const char* name, qboolean bForce); int (*UI_FontStringWidth)(fontheader_t* font, const char* string, int maxLen); - int (*Key_StringToKeynum)(char* str); - char* (*Key_KeynumToBindString)(int keyNum); - void (*Key_GetKeysForCommand)(char* command, int* key1, int* key2); + int (*Key_StringToKeynum)(const char* str); + const char* (*Key_KeynumToBindString)(int keyNum); + void (*Key_GetKeysForCommand)(const char* command, int* key1, int* key2); // ==================== TIKI STUFF ========================== // TIKI SPECIFIC STUFF dtiki_t* (*R_Model_GetHandle)(qhandle_t handle); int (*TIKI_NumAnims)(dtiki_t* pmdl); void (*TIKI_CalculateBounds)(dtiki_t* pmdl, float scale, vec3_t mins, vec3_t maxs); - char* (*TIKI_Name)(dtiki_t* tiki); + const char* (*TIKI_Name)(dtiki_t* tiki); void* (*TIKI_GetSkeletor)(dtiki_t* tiki, int entNum); void (*TIKI_SetEyeTargetPos)(dtiki_t* tiki, int entNum, vec3_t pos); @@ -347,13 +347,13 @@ typedef struct const char* data2, const char* data3, const char* data4, const char* data5, const char* data6, const char* data7, - const char* data8, const float* textColor, - const float* backColor, qboolean isHeader); + const char* data8, const vec4_t textColor, + const vec4_t backColor, qboolean isHeader); void (*UI_DeleteScoreBoardItems)(int maxIndex); void (*UI_ToggleDMMessageConsole)(int consoleMode); dtiki_t* (*TIKI_FindTiki)(const char* path); void (*LoadResource)(const char* name); - void (*FS_CanonicalFilename)(const char* name); + void (*FS_CanonicalFilename)(char* name); cvar_t* fsDebug; hdelement_t* HudDrawElements; diff --git a/code/cgame/cg_servercmds.c b/code/cgame/cg_servercmds.c index 572f0325..953a2294 100644 --- a/code/cgame/cg_servercmds.c +++ b/code/cgame/cg_servercmds.c @@ -156,8 +156,8 @@ static void CG_Stopwatch_f() Com_Error(1, "stopwatch didn't have 2 parameters"); } - cgi.stopWatch->startTime = 1000 * atoi(cgi.Argv(1)); - cgi.stopWatch->endTime = cgi.stopWatch->startTime + 1000 * atoi(cgi.Argv(2)); + cgi.stopWatch->iStartTime = 1000 * atoi(cgi.Argv(1)); + cgi.stopWatch->iEndTime = cgi.stopWatch->iStartTime + 1000 * atoi(cgi.Argv(2)); } /* @@ -240,10 +240,10 @@ Execute all of the server commands that were received along with this this snapshot. ==================== */ -void CG_ExecuteNewServerCommands(int latestSequence) +void CG_ExecuteNewServerCommands(int latestSequence, qboolean differentServer) { while (cgs.serverCommandSequence < latestSequence) { - if (cgi.GetServerCommand(++cgs.serverCommandSequence)) { + if (cgi.GetServerCommand(++cgs.serverCommandSequence, differentServer)) { CG_ServerCommand(); } } diff --git a/code/client/cl_cgame.cpp b/code/client/cl_cgame.cpp index 70b0e865..aa69ae9e 100644 --- a/code/client/cl_cgame.cpp +++ b/code/client/cl_cgame.cpp @@ -23,11 +23,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "client.h" #include "cl_ui.h" -#include "../botlib/botlib.h" +#include "tiki.h" #include -extern botlib_export_t *botlib_export; - extern qboolean loadCamera(const char *name); extern void startCamera(int time); extern qboolean getCameraInfo(int time, vec3_t *origin, vec3_t *angles); @@ -47,33 +45,30 @@ CL_GetGlconfig ==================== */ void CL_GetGlconfig( glconfig_t *glconfig ) { - glconfig_ver19_t *pgl = ( glconfig_ver19_t * )glconfig; - - strncpy( pgl->renderer_string, cls.glconfig.renderer_string, sizeof( pgl->renderer_string ) ); - strncpy( pgl->vendor_string, cls.glconfig.vendor_string, sizeof( pgl->vendor_string ) ); - strncpy( pgl->version_string, cls.glconfig.version_string, sizeof( pgl->version_string ) ); - strncpy( pgl->extensions_string, cls.glconfig.extensions_string, sizeof( pgl->extensions_string ) ); - pgl->maxTextureSize = cls.glconfig.maxTextureSize; - pgl->numTextureUnits = cls.glconfig.numTextureUnits; - pgl->colorBits = cls.glconfig.colorBits; - pgl->depthBits = cls.glconfig.depthBits; - pgl->stencilBits = cls.glconfig.stencilBits; - pgl->driverType = cls.glconfig.driverType; - pgl->hardwareType = cls.glconfig.hardwareType; - pgl->deviceSupportsGamma = cls.glconfig.deviceSupportsGamma; - pgl->textureCompression = cls.glconfig.textureCompression; - pgl->textureEnvAddAvailable = cls.glconfig.textureEnvAddAvailable; - pgl->vidWidth = cls.glconfig.vidWidth; - pgl->vidHeight = cls.glconfig.vidHeight; - pgl->windowAspect = cls.glconfig.windowAspect; - pgl->displayFrequency = cls.glconfig.displayFrequency; - pgl->isFullscreen = cls.glconfig.isFullscreen; - pgl->stereoEnabled = cls.glconfig.stereoEnabled; - pgl->smpActive = cls.glconfig.smpActive; - pgl->registerCombinerAvailable = cls.glconfig.registerCombinerAvailable; - pgl->secondaryColorAvailable = cls.glconfig.secondaryColorAvailable; - pgl->VAR = cls.glconfig.VAR; - pgl->fence = cls.glconfig.fence; + strncpy( glconfig->renderer_string, cls.glconfig.renderer_string, sizeof( glconfig->renderer_string ) ); + strncpy( glconfig->vendor_string, cls.glconfig.vendor_string, sizeof( glconfig->vendor_string ) ); + strncpy( glconfig->version_string, cls.glconfig.version_string, sizeof( glconfig->version_string ) ); + strncpy( glconfig->extensions_string, cls.glconfig.extensions_string, sizeof( glconfig->extensions_string ) ); + glconfig->maxTextureSize = cls.glconfig.maxTextureSize; + glconfig->colorBits = cls.glconfig.colorBits; + glconfig->depthBits = cls.glconfig.depthBits; + glconfig->stencilBits = cls.glconfig.stencilBits; + glconfig->driverType = cls.glconfig.driverType; + glconfig->hardwareType = cls.glconfig.hardwareType; + glconfig->deviceSupportsGamma = cls.glconfig.deviceSupportsGamma; + glconfig->textureCompression = cls.glconfig.textureCompression; + glconfig->textureEnvAddAvailable = cls.glconfig.textureEnvAddAvailable; + glconfig->vidWidth = cls.glconfig.vidWidth; + glconfig->vidHeight = cls.glconfig.vidHeight; + glconfig->windowAspect = cls.glconfig.windowAspect; + glconfig->displayFrequency = cls.glconfig.displayFrequency; + glconfig->isFullscreen = cls.glconfig.isFullscreen; + glconfig->stereoEnabled = cls.glconfig.stereoEnabled; + glconfig->smpActive = cls.glconfig.smpActive; + glconfig->registerCombinerAvailable = cls.glconfig.registerCombinerAvailable; + glconfig->secondaryColorAvailable = cls.glconfig.secondaryColorAvailable; + glconfig->VAR = cls.glconfig.VAR; + glconfig->fence = cls.glconfig.fence; } @@ -205,9 +200,9 @@ qboolean CL_GetSnapshot( int snapshotNumber, snapshot_t *snapshot ) { // wombat: sounds count = clSnap->number_of_sounds; - if ( snapshot->number_of_sounds > MAX_SOUNDS_IN_SNAPSHOT ) { - Com_DPrintf( "CL_GetSnapshot: truncated %i sounds to %i\n", count, MAX_SOUNDS_IN_SNAPSHOT ); - count = MAX_SOUNDS_IN_SNAPSHOT; + if ( snapshot->number_of_sounds > MAX_SERVER_SOUNDS) { + Com_DPrintf( "CL_GetSnapshot: truncated %i sounds to %i\n", count, MAX_SERVER_SOUNDS); + count = MAX_SERVER_SOUNDS; } snapshot->number_of_sounds = count; Com_Memcpy( snapshot->sounds, clSnap->sounds, sizeof(snapshot->sounds[0])*count ); @@ -441,7 +436,7 @@ void CL_CM_LoadMap( const char *mapname ) { CL_CG_Malloc ==================== */ -void *CL_CG_Malloc( int size ) +void *CL_CG_Malloc(int size ) { return Z_TagMalloc( size, TAG_CGAME ); } @@ -523,8 +518,8 @@ sfxHandle_t CL_RegisterSound( const char *sample, qboolean streamed ) { CL_StartLocalSound ==================== */ -void CL_StartLocalSound( const char *sound_name ) { - S_StartLocalSound( sound_name, qfalse ); +void CL_StartLocalSound(const char* soundName, qboolean forceLoad) { + S_StartLocalSound(soundName, qfalse ); } /* @@ -739,10 +734,11 @@ void CL_InitCGameDLL( clientGameImport_t *cgi, clientGameExport_t **cge ) { cgi->FS_CanonicalFilename = FS_CanonicalFilename; cgi->fsDebug = fs_debug; - cgi->hudDrawElements = cls.HudDrawElements; + cgi->HudDrawElements = cls.HudDrawElements; cgi->anim = &cls.anim; cgi->stopWatch = &cls.stopwatch; - cgi->pUnknownVar = NULL; + // FIXME + //cgi->pUnknownVar = NULL; cls.cgameStarted = qtrue; } @@ -756,20 +752,20 @@ static void CL_ViewModelAnimation_Init() { int i; for( i = 0; i < MAX_FRAMEINFOS; i++ ) { - cls.anim.vmFrameInfo[ i ].index = 0; - cls.anim.vmFrameInfo[ i ].time = 0.0; - cls.anim.vmFrameInfo[ i ].weight = 0.0; + cls.anim.g_VMFrameInfo[ i ].index = 0; + cls.anim.g_VMFrameInfo[ i ].time = 0.0; + cls.anim.g_VMFrameInfo[ i ].weight = 0.0; } - VectorClear( cls.anim.currentVMPosOffset ); - cls.anim.lastVMAnim = -1; - cls.anim.lastVMAnimChanged = -1; - cls.anim.currentVMAnimSlot = 0; - cls.anim.currentVMDuration = 9999; - cls.anim.crossBlending = qfalse; - cls.anim.lastEquippedWeaponStat = -1; - cls.anim.lastActiveItem[ 0 ] = 0; - cls.anim.lastAnimPrefixIndex = 0; + VectorClear( cls.anim.g_vCurrentVMPosOffset ); + cls.anim.g_iLastVMAnim = -1; + cls.anim.g_iLastVMAnimChanged = -1; + cls.anim.g_iCurrentVMAnimSlot = 0; + cls.anim.g_iCurrentVMDuration = 9999; + cls.anim.g_bCrossblending = qfalse; + cls.anim.g_iLastEquippedWeaponStat = -1; + cls.anim.g_szLastActiveItem[ 0 ] = 0; + cls.anim.g_iLastAnimPrefixIndex = 0; } /* diff --git a/code/client/cl_console.cpp b/code/client/cl_console.cpp deleted file mode 100644 index be1c5ff6..00000000 --- a/code/client/cl_console.cpp +++ /dev/null @@ -1,789 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -// console.c - -#include "client.h" - - -int g_console_field_width = 78; -int g_console_charWidth = SMALLCHAR_WIDTH, g_console_charHeight = SMALLCHAR_HEIGHT; - -#define NUM_CON_TIMES 4 - -#define CON_TEXTSIZE 32768 -typedef struct { - qboolean initialized; - - short text[CON_TEXTSIZE]; - int current; // line where next message will be printed - int x; // offset in current line for next print - int display; // bottom of console displays this line - - int linewidth; // characters across screen - int totallines; // total lines in console scrollback - - float xadjust; // for wide aspect screens - - float displayFrac; // aproaches finalFrac at scr_conspeed - float finalFrac; // 0.0 to 1.0 lines of console to display - - int vislines; // in scanlines - - int times[NUM_CON_TIMES]; // cls.realtime time the line was generated - // for transparent notify lines - vec4_t color; -} console_t; - -extern console_t con; - -console_t con; - -cvar_t *con_conspeed; -cvar_t *con_notifytime; -cvar_t *con_drawnotify; - -#define DEFAULT_CONSOLE_WIDTH 78 - -vec4_t console_color = {1.0, 1.0, 1.0, 1.0}; - - -/* -================ -Con_ToggleConsole_f -================ -*/ -void Con_ToggleConsole_f (void) { - // Can't toggle the console when it's the only thing available - if ( cls.state == CA_DISCONNECTED && Key_GetCatcher( ) == KEYCATCH_CONSOLE ) { - return; - } - - Field_Clear( &g_consoleField ); - g_consoleField.widthInChars = g_console_field_width; - - Con_ClearNotify (); - Key_SetCatcher( Key_GetCatcher( ) ^ KEYCATCH_CONSOLE ); -} - -/* -================ -Con_MessageMode_f -================ -*/ -void Con_MessageMode_f (void) { - chat_playerNum = -1; - chat_team = qfalse; - Field_Clear( &chatField ); - chatField.widthInChars = 30; - - Key_SetCatcher( Key_GetCatcher( ) ^ KEYCATCH_MESSAGE ); -} - -/* -================ -Con_MessageMode2_f -================ -*/ -void Con_MessageMode2_f (void) { - chat_playerNum = -1; - chat_team = qtrue; - Field_Clear( &chatField ); - chatField.widthInChars = 25; - Key_SetCatcher( Key_GetCatcher( ) ^ KEYCATCH_MESSAGE ); -} - -/* -================ -Con_MessageMode3_f -================ -*/ -void Con_MessageMode3_f (void) { - chat_team = qfalse; - Field_Clear( &chatField ); - chatField.widthInChars = 30; - Key_SetCatcher( Key_GetCatcher( ) ^ KEYCATCH_MESSAGE ); -} - -/* -================ -Con_MessageMode4_f -================ -*/ -void Con_MessageMode4_f (void) { - chat_team = qfalse; - Field_Clear( &chatField ); - chatField.widthInChars = 30; - Key_SetCatcher( Key_GetCatcher( ) ^ KEYCATCH_MESSAGE ); -} - -/* -================ -Con_Clear_f -================ -*/ -void Con_Clear_f (void) { - int i; - - for ( i = 0 ; i < CON_TEXTSIZE ; i++ ) { - con.text[i] = (ColorIndex(COLOR_WHITE)<<8) | ' '; - } - - Con_Bottom(); // go to end -} - - -/* -================ -Con_Dump_f - -Save the console contents out to a file -================ -*/ -void Con_Dump_f (void) -{ - int l, x, i; - short *line; - fileHandle_t f; - char buffer[1024]; - - if (Cmd_Argc() != 2) - { - Com_Printf ("usage: condump \n"); - return; - } - - Com_Printf ("Dumped console text to %s.\n", Cmd_Argv(1) ); - - f = FS_FOpenFileWrite( Cmd_Argv( 1 ) ); - if (!f) - { - Com_Printf ("ERROR: couldn't open.\n"); - return; - } - - // skip empty lines - for (l = con.current - con.totallines + 1 ; l <= con.current ; l++) - { - line = con.text + (l%con.totallines)*con.linewidth; - for (x=0 ; x=0 ; x--) - { - if (buffer[x] == ' ') - buffer[x] = 0; - else - break; - } - strcat( buffer, "\n" ); - FS_Write(buffer, strlen(buffer), f); - } - - FS_FCloseFile( f ); -} - - -/* -================ -Con_ClearNotify -================ -*/ -void Con_ClearNotify( void ) { - int i; - - for ( i = 0 ; i < NUM_CON_TIMES ; i++ ) { - con.times[i] = 0; - } -} - - - -/* -================ -Con_CheckResize - -If the line width has changed, reformat the buffer. -================ -*/ -void Con_CheckResize (void) -{ - int i, j, width, oldwidth, oldtotallines, numlines, numchars; - short tbuf[CON_TEXTSIZE]; - - width = (SCREEN_WIDTH / g_console_charWidth) - 2; - - if (width == con.linewidth) - return; - - if (width < 1) // video hasn't been initialized yet - { - width = DEFAULT_CONSOLE_WIDTH; - con.linewidth = width; - con.totallines = CON_TEXTSIZE / con.linewidth; - for(i=0; i= 0) - { - if (skipnotify) - con.times[con.current % NUM_CON_TIMES] = 0; - else - con.times[con.current % NUM_CON_TIMES] = cls.realtime; - } - - con.x = 0; - if (con.display == con.current) - con.display++; - con.current++; - for(i=0; iinteger ) { - return; - } - - if (!con.initialized) { - con.color[0] = - con.color[1] = - con.color[2] = - con.color[3] = 1.0f; - con.linewidth = -1; - Con_CheckResize (); - con.initialized = qtrue; - } - - color = ColorIndex(COLOR_WHITE); - - while ( (c = *txt) != 0 ) { - if ( Q_IsColorString( txt ) ) { - color = ColorIndex( *(txt+1) ); - txt += 2; - continue; - } - - // count word length - for (l=0 ; l< con.linewidth ; l++) { - if ( txt[l] <= ' ') { - break; - } - - } - - // word wrap - if (l != con.linewidth && (con.x + l >= con.linewidth) ) { - Con_Linefeed(skipnotify); - - } - - txt++; - - switch (c) - { - case '\n': - Con_Linefeed (skipnotify); - break; - case '\r': - con.x = 0; - break; - default: // display character and advance - y = con.current % con.totallines; - con.text[y*con.linewidth+con.x] = (color << 8) | c; - con.x++; - if (con.x >= con.linewidth) { - Con_Linefeed(skipnotify); - con.x = 0; - } - break; - } - } - - - // mark time for transparent overlay - if (con.current >= 0) { - // NERVE - SMF - if ( skipnotify ) { - prev = con.current % NUM_CON_TIMES - 1; - if ( prev < 0 ) - prev = NUM_CON_TIMES - 1; - con.times[prev] = 0; - } - else - // -NERVE - SMF - con.times[con.current % NUM_CON_TIMES] = cls.realtime; - } -} - - -/* -============================================================================== - -DRAWING - -============================================================================== -*/ - - -/* -================ -Con_DrawInput - -Draw the editline after a ] prompt -================ -*/ -void Con_DrawInput (void) { - int y; - - if ( cls.state != CA_DISCONNECTED && !(Key_GetCatcher( ) & KEYCATCH_CONSOLE ) ) { - return; - } - - y = con.vislines - ( g_console_charHeight * 2 ); - - re.SetColor( con.color ); - - re.Text_PaintChar(&cls.consoleFont, con.xadjust + 1 * g_console_charWidth, y, 1.f, ']', 0); - - Field_Draw(&cls.consoleFont, &g_consoleField, con.xadjust + 2 * g_console_charWidth, y, - SCREEN_WIDTH - 3 * g_console_charWidth, qtrue, qtrue); -} - - -/* -================ -Con_DrawNotify - -Draws the last few lines of output transparently over the game top -================ -*/ -void Con_DrawNotify (void) -{ - int x, v; - short *text; - int i; - int time; - int skip; - int currentColor; - - currentColor = 7; - re.SetColor( g_color_table[currentColor] ); - - v = 0; - for (i= con.current-NUM_CON_TIMES+1 ; i<=con.current ; i++) - { - if (i < 0) - continue; - time = con.times[i % NUM_CON_TIMES]; - if (time == 0) - continue; - time = cls.realtime - time; - if (time > con_notifytime->value*1000) - continue; - text = con.text + (i % con.totallines)*con.linewidth; - - if (Key_GetCatcher( ) & (KEYCATCH_UI | KEYCATCH_CGAME) ) { - continue; - } - - for (x = 0 ; x < con.linewidth ; x++) { - if ( ( text[x] & 0xff ) == ' ' ) { - continue; - } - if ( ( (text[x]>>8)&7 ) != currentColor ) { - currentColor = (text[x]>>8)&7; - re.SetColor( g_color_table[currentColor] ); - } - re.Text_PaintChar(&cls.consoleFont, cl_conXOffset->integer + con.xadjust + (x+1)*g_console_charWidth, v, 1.f, text[x] & 0xff,0); - } - - v += g_console_charHeight; - } - - re.SetColor( NULL ); - - if (Key_GetCatcher( ) & (KEYCATCH_UI | KEYCATCH_CGAME) ) { - return; - } - - // draw the chat line - if ( Key_GetCatcher( ) & KEYCATCH_MESSAGE ) - { - if (chat_team) - { - //SCR_DrawBigString (8, v, "say_team:", 1.0f, qfalse ); - re.Text_Paint(&cls.consoleFont, 8, v, 1.f, 1.f, "say_team:", 0, 0, qtrue,qfalse); - skip = 10; - } - else - { - //SCR_DrawBigString (8, v, "say:", 1.0f, qfalse ); - re.Text_Paint(&cls.consoleFont, 8, v, 1.f, 1.f, "say:", 0, 0, qtrue,qfalse); - skip = 5; - } - - // TODO: make this use facfont? - Field_BigDraw(&cls.consoleFont, &chatField, skip * g_console_charWidth, v, - SCREEN_WIDTH - ( skip + 1 ) * g_console_charWidth, qtrue, qtrue ); - - v += g_console_charHeight; - } - -} - -/* -================ -Con_DrawSolidConsole - -Draws the console with the solid background -================ -*/ -void Con_DrawSolidConsole( float frac ) { - int i, x, y; - int rows; - short *text; - int row; - int lines; -// qhandle_t conShader; - int currentColor; - vec4_t color; - - lines = cls.glconfig.vidHeight * frac; - if (lines <= 0) - return; - - if (lines > cls.glconfig.vidHeight ) - lines = cls.glconfig.vidHeight; - - // on wide screens, we will center the text - con.xadjust = 0; - SCR_AdjustFrom640( &con.xadjust, NULL, NULL, NULL ); - - // draw the background - y = frac * SCREEN_HEIGHT - 2; - if ( y < 1 ) { - y = 0; - } - else { - //SCR_DrawPic( 0, 0, SCREEN_WIDTH, y, cls.consoleShader ); - // IneQuation: transparent MoHAA-style console - color[0] = 0.1125f; - color[1] = 0.15f; - color[2] = 0.21f; - color[3] = 0.85f; - SCR_FillRect(0, 0, SCREEN_WIDTH, y, color); - } - - color[0] = 0.7f; - color[1] = 0.6f; - color[2] = 0.05f; - color[3] = 1; - SCR_FillRect( 0, y, SCREEN_WIDTH, 2, color ); - - - // draw the version number - - /*color[0] = 0.7; - color[1] = 0.6; - color[2] = 0.05; - color[3] = 1;*/ - re.SetColor( color/*g_color_table[ColorIndex(COLOR_RED)]*/ ); - - i = strlen( Q3_VERSION ); - - for (x=0 ; x= con.totallines) { - // past scrollback wrap point - continue; - } - - text = con.text + (row % con.totallines)*con.linewidth; - - for (x=0 ; x>8)&7 ) != currentColor ) { - currentColor = (text[x]>>8)&7; - re.SetColor(g_color_table[currentColor]); - } - re.Text_PaintChar(&cls.consoleFont, con.xadjust + (x+1)*g_console_charWidth, y, 1.f, text[x] & 0xff,0); - } - } - - // draw the input prompt, user text, and cursor if desired - Con_DrawInput (); - - re.SetColor( NULL ); -} - - - -/* -================== -Con_DrawConsole -================== -*/ -void Con_DrawConsole( void ) { - // check for console width changes from a vid mode change - Con_CheckResize (); - - // if disconnected, render console full screen - if ( cls.state == CA_DISCONNECTED ) { - if ( !( Key_GetCatcher( ) & (KEYCATCH_UI | KEYCATCH_CGAME)) ) { - Con_DrawSolidConsole( 1.0 ); - return; - } - } - - if ( con.displayFrac ) { - Con_DrawSolidConsole( con.displayFrac ); - } else { - // draw notify lines - if ( cls.state == CA_ACTIVE && con_drawnotify->integer ) { - Con_DrawNotify (); - } - } -} - -//================================================================ - -/* -================== -Con_RunConsole - -Scroll it up or down -================== -*/ -void Con_RunConsole (void) { - // decide on the destination height of the console - if ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) - con.finalFrac = 0.5; // half screen - else - con.finalFrac = 0; // none visible - - // scroll towards the destination height - if (con.finalFrac < con.displayFrac) - { - con.displayFrac -= con_conspeed->value*cls.realFrametime*0.001; - if (con.finalFrac > con.displayFrac) - con.displayFrac = con.finalFrac; - - } - else if (con.finalFrac > con.displayFrac) - { - con.displayFrac += con_conspeed->value*cls.realFrametime*0.001; - if (con.finalFrac < con.displayFrac) - con.displayFrac = con.finalFrac; - } - -} - - -void Con_PageUp( void ) { - con.display -= 2; - if ( con.current - con.display >= con.totallines ) { - con.display = con.current - con.totallines + 1; - } -} - -void Con_PageDown( void ) { - con.display += 2; - if (con.display > con.current) { - con.display = con.current; - } -} - -void Con_Top( void ) { - con.display = con.totallines; - if ( con.current - con.display >= con.totallines ) { - con.display = con.current - con.totallines + 1; - } -} - -void Con_Bottom( void ) { - con.display = con.current; -} - - -void Con_Close( void ) { - if ( !com_cl_running->integer ) { - return; - } - Field_Clear( &g_consoleField ); - Con_ClearNotify (); - Key_SetCatcher( Key_GetCatcher( ) & ~KEYCATCH_CONSOLE ); - con.finalFrac = 0; // none visible - con.displayFrac = 0; -} diff --git a/code/client/cl_consolecmds.cpp b/code/client/cl_consolecmds.cpp index 2e39f3b4..61edea37 100644 --- a/code/client/cl_consolecmds.cpp +++ b/code/client/cl_consolecmds.cpp @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // cl_consolecmds.cpp : New client console commands. #include "client.h" -#include "glb_local.h" +#include "listener.h" /* =============== diff --git a/code/client/cl_main.cpp b/code/client/cl_main.cpp index 0092cb40..195080a8 100644 --- a/code/client/cl_main.cpp +++ b/code/client/cl_main.cpp @@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "client.h" #include "server.h" #include "cl_ui.h" +#include "tiki.h" #include #include "../sys/sys_local.h" #include @@ -407,7 +408,8 @@ void CL_Record_f( void ) { continue; } MSG_WriteByte (&buf, svc_baseline); - MSG_WriteDeltaEntity (&buf, &nullstate, ent, qtrue ); + // FIXME + MSG_WriteDeltaEntity (&buf, &nullstate, ent, qtrue, 0.0 ); } MSG_WriteByte( &buf, svc_EOF ); @@ -2588,7 +2590,7 @@ void CL_StartHunkUsers( void ) { CL_RefMalloc ============ */ -void *CL_RefMalloc( int size ) { +void *CL_RefMalloc(size_t size ) { return Z_TagMalloc( size, TAG_RENDERER ); } diff --git a/code/client/cl_parse.cpp b/code/client/cl_parse.cpp index ead29765..d210edc4 100644 --- a/code/client/cl_parse.cpp +++ b/code/client/cl_parse.cpp @@ -74,7 +74,8 @@ void CL_DeltaEntity (msg_t *msg, clSnapshot_t *frame, int newnum, entityState_t if ( unchanged ) { *state = *old; } else { - MSG_ReadDeltaEntity( msg, old, state, newnum ); + // FIXME: frametime + MSG_ReadDeltaEntity( msg, old, state, newnum, 0.0); } if ( state->number == (MAX_GENTITIES-1) ) { @@ -271,11 +272,12 @@ void CL_ParseSnapshot( msg_t *msg ) { MSG_ReadData( msg, &newSnap.areamask, len); // read playerinfo - SHOWNET( msg, "playerstate" ); + SHOWNET(msg, "playerstate"); + // FIXME: frametime if ( old ) { - MSG_ReadDeltaPlayerstate( msg, &old->ps, &newSnap.ps ); + MSG_ReadDeltaPlayerstate( msg, &old->ps, &newSnap.ps, 0.0 ); } else { - MSG_ReadDeltaPlayerstate( msg, NULL, &newSnap.ps ); + MSG_ReadDeltaPlayerstate( msg, NULL, &newSnap.ps, 0.0); } // read packet entities @@ -500,7 +502,8 @@ void CL_ParseGamestate( msg_t *msg ) { //Com_Memset (&nullstate, 0, sizeof(nullstate)); MSG_GetNullEntityState(&nullstate); es = &cl.entityBaselines[ newnum ]; - MSG_ReadDeltaEntity( msg, &nullstate, es, newnum ); + // FIXME: frametime + MSG_ReadDeltaEntity( msg, &nullstate, es, newnum, 0.0); } else { Com_Error( ERR_DROP, "CL_ParseGamestate: bad command byte %i", cmd ); } diff --git a/code/client/cl_ui.c b/code/client/cl_ui.c deleted file mode 100644 index 7e663095..00000000 --- a/code/client/cl_ui.c +++ /dev/null @@ -1,1212 +0,0 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ - -#include "client.h" - -#include "../botlib/botlib.h" -#include "../qcommon/tiki_local.h" -#include "../uilib/ui_public.h" - -extern botlib_export_t *botlib_export; - -vm_t *uivm; - -uiexport_t uie; - -/* -==================== -GetClientState -==================== -*/ -static void GetClientState( uiClientState_t *state ) { - state->connectPacketCount = clc.connectPacketCount; - state->connState = cls.state; - Q_strncpyz( state->servername, cls.servername, sizeof( state->servername ) ); - Q_strncpyz( state->updateInfoString, cls.updateInfoString, sizeof( state->updateInfoString ) ); - Q_strncpyz( state->messageString, clc.serverMessage, sizeof( state->messageString ) ); - state->clientNum = cl.snap.ps.clientNum; -} - -/* -==================== -LAN_LoadCachedServers -==================== -*/ -void LAN_LoadCachedServers( void ) { - int size; - fileHandle_t fileIn; - cls.numglobalservers = cls.nummplayerservers = cls.numfavoriteservers = 0; - cls.numGlobalServerAddresses = 0; - if (FS_SV_FOpenFileRead("servercache.dat", &fileIn)) { - FS_Read(&cls.numglobalservers, sizeof(int), fileIn); - FS_Read(&cls.nummplayerservers, sizeof(int), fileIn); - FS_Read(&cls.numfavoriteservers, sizeof(int), fileIn); - FS_Read(&size, sizeof(int), fileIn); - if (size == sizeof(cls.globalServers) + sizeof(cls.favoriteServers) + sizeof(cls.mplayerServers)) { - FS_Read(&cls.globalServers, sizeof(cls.globalServers), fileIn); - FS_Read(&cls.mplayerServers, sizeof(cls.mplayerServers), fileIn); - FS_Read(&cls.favoriteServers, sizeof(cls.favoriteServers), fileIn); - } else { - cls.numglobalservers = cls.nummplayerservers = cls.numfavoriteservers = 0; - cls.numGlobalServerAddresses = 0; - } - FS_FCloseFile(fileIn); - } -} - -/* -==================== -LAN_SaveServersToCache -==================== -*/ -void LAN_SaveServersToCache( void ) { - int size; - fileHandle_t fileOut = FS_SV_FOpenFileWrite("servercache.dat"); - FS_Write(&cls.numglobalservers, sizeof(int), fileOut); - FS_Write(&cls.nummplayerservers, sizeof(int), fileOut); - FS_Write(&cls.numfavoriteservers, sizeof(int), fileOut); - size = sizeof(cls.globalServers) + sizeof(cls.favoriteServers) + sizeof(cls.mplayerServers); - FS_Write(&size, sizeof(int), fileOut); - FS_Write(&cls.globalServers, sizeof(cls.globalServers), fileOut); - FS_Write(&cls.mplayerServers, sizeof(cls.mplayerServers), fileOut); - FS_Write(&cls.favoriteServers, sizeof(cls.favoriteServers), fileOut); - FS_FCloseFile(fileOut); -} - - -/* -==================== -LAN_ResetPings -==================== -*/ -static void LAN_ResetPings(int source) { - int count,i; - serverInfo_t *servers = NULL; - count = 0; - - switch (source) { - case AS_LOCAL : - servers = &cls.localServers[0]; - count = MAX_OTHER_SERVERS; - break; - case AS_MPLAYER : - servers = &cls.mplayerServers[0]; - count = MAX_OTHER_SERVERS; - break; - case AS_GLOBAL : - servers = &cls.globalServers[0]; - count = MAX_GLOBAL_SERVERS; - break; - case AS_FAVORITES : - servers = &cls.favoriteServers[0]; - count = MAX_OTHER_SERVERS; - break; - } - if (servers) { - for (i = 0; i < count; i++) { - servers[i].ping = -1; - } - } -} - -/* -==================== -LAN_AddServer -==================== -*/ -static int LAN_AddServer(int source, const char *name, const char *address) { - int max, *count, i; - netadr_t adr; - serverInfo_t *servers = NULL; - max = MAX_OTHER_SERVERS; - count = NULL; - - switch (source) { - case AS_LOCAL : - count = &cls.numlocalservers; - servers = &cls.localServers[0]; - break; - case AS_MPLAYER : - count = &cls.nummplayerservers; - servers = &cls.mplayerServers[0]; - break; - case AS_GLOBAL : - max = MAX_GLOBAL_SERVERS; - count = &cls.numglobalservers; - servers = &cls.globalServers[0]; - break; - case AS_FAVORITES : - count = &cls.numfavoriteservers; - servers = &cls.favoriteServers[0]; - break; - } - if (servers && *count < max) { - NET_StringToAdr( address, &adr ); - for ( i = 0; i < *count; i++ ) { - if (NET_CompareAdr(servers[i].adr, adr)) { - break; - } - } - if (i >= *count) { - servers[*count].adr = adr; - Q_strncpyz(servers[*count].hostName, name, sizeof(servers[*count].hostName)); - servers[*count].visible = qtrue; - (*count)++; - return 1; - } - return 0; - } - return -1; -} - -/* -==================== -LAN_RemoveServer -==================== -*/ -static void LAN_RemoveServer(int source, const char *addr) { - int *count, i; - serverInfo_t *servers = NULL; - count = NULL; - switch (source) { - case AS_LOCAL : - count = &cls.numlocalservers; - servers = &cls.localServers[0]; - break; - case AS_MPLAYER : - count = &cls.nummplayerservers; - servers = &cls.mplayerServers[0]; - break; - case AS_GLOBAL : - count = &cls.numglobalservers; - servers = &cls.globalServers[0]; - break; - case AS_FAVORITES : - count = &cls.numfavoriteservers; - servers = &cls.favoriteServers[0]; - break; - } - if (servers) { - netadr_t comp; - NET_StringToAdr( addr, &comp ); - for (i = 0; i < *count; i++) { - if (NET_CompareAdr( comp, servers[i].adr)) { - int j = i; - while (j < *count - 1) { - Com_Memcpy(&servers[j], &servers[j+1], sizeof(servers[j])); - j++; - } - (*count)--; - break; - } - } - } -} - - -/* -==================== -LAN_GetServerCount -==================== -*/ -static int LAN_GetServerCount( int source ) { - switch (source) { - case AS_LOCAL : - return cls.numlocalservers; - break; - case AS_MPLAYER : - return cls.nummplayerservers; - break; - case AS_GLOBAL : - return cls.numglobalservers; - break; - case AS_FAVORITES : - return cls.numfavoriteservers; - break; - } - return 0; -} - -/* -==================== -LAN_GetLocalServerAddressString -==================== -*/ -static void LAN_GetServerAddressString( int source, int n, char *buf, int buflen ) { - switch (source) { - case AS_LOCAL : - if (n >= 0 && n < MAX_OTHER_SERVERS) { - Q_strncpyz(buf, NET_AdrToString( cls.localServers[n].adr) , buflen ); - return; - } - break; - case AS_MPLAYER : - if (n >= 0 && n < MAX_OTHER_SERVERS) { - Q_strncpyz(buf, NET_AdrToString( cls.mplayerServers[n].adr) , buflen ); - return; - } - break; - case AS_GLOBAL : - if (n >= 0 && n < MAX_GLOBAL_SERVERS) { - Q_strncpyz(buf, NET_AdrToString( cls.globalServers[n].adr) , buflen ); - return; - } - break; - case AS_FAVORITES : - if (n >= 0 && n < MAX_OTHER_SERVERS) { - Q_strncpyz(buf, NET_AdrToString( cls.favoriteServers[n].adr) , buflen ); - return; - } - break; - } - buf[0] = '\0'; -} - -/* -==================== -LAN_GetServerInfo -==================== -*/ -static void LAN_GetServerInfo( int source, int n, char *buf, int buflen ) { - char info[MAX_STRING_CHARS]; - serverInfo_t *server = NULL; - info[0] = '\0'; - switch (source) { - case AS_LOCAL : - if (n >= 0 && n < MAX_OTHER_SERVERS) { - server = &cls.localServers[n]; - } - break; - case AS_MPLAYER : - if (n >= 0 && n < MAX_OTHER_SERVERS) { - server = &cls.mplayerServers[n]; - } - break; - case AS_GLOBAL : - if (n >= 0 && n < MAX_GLOBAL_SERVERS) { - server = &cls.globalServers[n]; - } - break; - case AS_FAVORITES : - if (n >= 0 && n < MAX_OTHER_SERVERS) { - server = &cls.favoriteServers[n]; - } - break; - } - if (server && buf) { - buf[0] = '\0'; - Info_SetValueForKey( info, "hostname", server->hostName); - Info_SetValueForKey( info, "mapname", server->mapName); - Info_SetValueForKey( info, "clients", va("%i",server->clients)); - Info_SetValueForKey( info, "sv_maxclients", va("%i",server->maxClients)); - Info_SetValueForKey( info, "ping", va("%i",server->ping)); - Info_SetValueForKey( info, "minping", va("%i",server->minPing)); - Info_SetValueForKey( info, "maxping", va("%i",server->maxPing)); - Info_SetValueForKey( info, "game", server->game); - Info_SetValueForKey( info, "gametype", va("%i",server->gameType)); - Info_SetValueForKey( info, "nettype", va("%i",server->netType)); - Info_SetValueForKey( info, "addr", NET_AdrToString(server->adr)); - Info_SetValueForKey( info, "punkbuster", va("%i", server->punkbuster)); - Q_strncpyz(buf, info, buflen); - } else { - if (buf) { - buf[0] = '\0'; - } - } -} - -/* -==================== -LAN_GetServerPing -==================== -*/ -static int LAN_GetServerPing( int source, int n ) { - serverInfo_t *server = NULL; - switch (source) { - case AS_LOCAL : - if (n >= 0 && n < MAX_OTHER_SERVERS) { - server = &cls.localServers[n]; - } - break; - case AS_MPLAYER : - if (n >= 0 && n < MAX_OTHER_SERVERS) { - server = &cls.mplayerServers[n]; - } - break; - case AS_GLOBAL : - if (n >= 0 && n < MAX_GLOBAL_SERVERS) { - server = &cls.globalServers[n]; - } - break; - case AS_FAVORITES : - if (n >= 0 && n < MAX_OTHER_SERVERS) { - server = &cls.favoriteServers[n]; - } - break; - } - if (server) { - return server->ping; - } - return -1; -} - -/* -==================== -LAN_GetServerPtr -==================== -*/ -static serverInfo_t *LAN_GetServerPtr( int source, int n ) { - switch (source) { - case AS_LOCAL : - if (n >= 0 && n < MAX_OTHER_SERVERS) { - return &cls.localServers[n]; - } - break; - case AS_MPLAYER : - if (n >= 0 && n < MAX_OTHER_SERVERS) { - return &cls.mplayerServers[n]; - } - break; - case AS_GLOBAL : - if (n >= 0 && n < MAX_GLOBAL_SERVERS) { - return &cls.globalServers[n]; - } - break; - case AS_FAVORITES : - if (n >= 0 && n < MAX_OTHER_SERVERS) { - return &cls.favoriteServers[n]; - } - break; - } - return NULL; -} - -/* -==================== -LAN_CompareServers -==================== -*/ -static int LAN_CompareServers( int source, int sortKey, int sortDir, int s1, int s2 ) { - int res; - serverInfo_t *server1, *server2; - - server1 = LAN_GetServerPtr(source, s1); - server2 = LAN_GetServerPtr(source, s2); - if (!server1 || !server2) { - return 0; - } - - res = 0; - switch( sortKey ) { - case SORT_HOST: - res = Q_stricmp( server1->hostName, server2->hostName ); - break; - - case SORT_MAP: - res = Q_stricmp( server1->mapName, server2->mapName ); - break; - case SORT_CLIENTS: - if (server1->clients < server2->clients) { - res = -1; - } - else if (server1->clients > server2->clients) { - res = 1; - } - else { - res = 0; - } - break; - case SORT_GAME: - if (server1->gameType < server2->gameType) { - res = -1; - } - else if (server1->gameType > server2->gameType) { - res = 1; - } - else { - res = 0; - } - break; - case SORT_PING: - if (server1->ping < server2->ping) { - res = -1; - } - else if (server1->ping > server2->ping) { - res = 1; - } - else { - res = 0; - } - break; - } - - if (sortDir) { - if (res < 0) - return 1; - if (res > 0) - return -1; - return 0; - } - return res; -} - -/* -==================== -LAN_GetPingQueueCount -==================== -*/ -static int LAN_GetPingQueueCount( void ) { - return (CL_GetPingQueueCount()); -} - -/* -==================== -LAN_ClearPing -==================== -*/ -static void LAN_ClearPing( int n ) { - CL_ClearPing( n ); -} - -/* -==================== -LAN_GetPing -==================== -*/ -static void LAN_GetPing( int n, char *buf, int buflen, int *pingtime ) { - CL_GetPing( n, buf, buflen, pingtime ); -} - -/* -==================== -LAN_GetPingInfo -==================== -*/ -static void LAN_GetPingInfo( int n, char *buf, int buflen ) { - CL_GetPingInfo( n, buf, buflen ); -} - -/* -==================== -LAN_MarkServerVisible -==================== -*/ -static void LAN_MarkServerVisible(int source, int n, qboolean visible ) { - if (n == -1) { - int count = MAX_OTHER_SERVERS; - serverInfo_t *server = NULL; - switch (source) { - case AS_LOCAL : - server = &cls.localServers[0]; - break; - case AS_MPLAYER : - server = &cls.mplayerServers[0]; - break; - case AS_GLOBAL : - server = &cls.globalServers[0]; - count = MAX_GLOBAL_SERVERS; - break; - case AS_FAVORITES : - server = &cls.favoriteServers[0]; - break; - } - if (server) { - for (n = 0; n < count; n++) { - server[n].visible = visible; - } - } - - } else { - switch (source) { - case AS_LOCAL : - if (n >= 0 && n < MAX_OTHER_SERVERS) { - cls.localServers[n].visible = visible; - } - break; - case AS_MPLAYER : - if (n >= 0 && n < MAX_OTHER_SERVERS) { - cls.mplayerServers[n].visible = visible; - } - break; - case AS_GLOBAL : - if (n >= 0 && n < MAX_GLOBAL_SERVERS) { - cls.globalServers[n].visible = visible; - } - break; - case AS_FAVORITES : - if (n >= 0 && n < MAX_OTHER_SERVERS) { - cls.favoriteServers[n].visible = visible; - } - break; - } - } -} - - -/* -======================= -LAN_ServerIsVisible -======================= -*/ -static int LAN_ServerIsVisible(int source, int n ) { - switch (source) { - case AS_LOCAL : - if (n >= 0 && n < MAX_OTHER_SERVERS) { - return cls.localServers[n].visible; - } - break; - case AS_MPLAYER : - if (n >= 0 && n < MAX_OTHER_SERVERS) { - return cls.mplayerServers[n].visible; - } - break; - case AS_GLOBAL : - if (n >= 0 && n < MAX_GLOBAL_SERVERS) { - return cls.globalServers[n].visible; - } - break; - case AS_FAVORITES : - if (n >= 0 && n < MAX_OTHER_SERVERS) { - return cls.favoriteServers[n].visible; - } - break; - } - return qfalse; -} - -/* -======================= -LAN_UpdateVisiblePings -======================= -*/ -qboolean LAN_UpdateVisiblePings(int source ) { - return CL_UpdateVisiblePings_f(source); -} - -/* -==================== -LAN_GetServerStatus -==================== -*/ -int LAN_GetServerStatus( char *serverAddress, char *serverStatus, int maxLen ) { - return CL_ServerStatus( serverAddress, serverStatus, maxLen ); -} - -/* -==================== -CL_GetGlConfig -==================== -*/ -static void CL_GetGlconfig( glconfig_t *config ) { - *config = cls.glconfig; -} - -/* -==================== -CL_GetClipboardData -==================== -*/ -static void CL_GetClipboardData( char *buf, int buflen ) { - char *cbd; - - cbd = Sys_GetClipboardData(); - - if ( !cbd ) { - *buf = 0; - return; - } - - Q_strncpyz( buf, cbd, buflen ); - - Z_Free( cbd ); -} - -/* -==================== -Key_KeynumToStringBuf -==================== -*/ -static void Key_KeynumToStringBuf( int keynum, char *buf, int buflen ) { - Q_strncpyz( buf, Key_KeynumToString( keynum ), buflen ); -} - -/* -==================== -Key_GetBindingBuf -==================== -*/ -static void Key_GetBindingBuf( int keynum, char *buf, int buflen ) { - char *value; - - value = Key_GetBinding( keynum ); - if ( value ) { - Q_strncpyz( buf, value, buflen ); - } - else { - *buf = 0; - } -} - -/* -==================== -CLUI_GetCDKey -==================== -*/ -static void CLUI_GetCDKey( char *buf, int buflen ) { - cvar_t *fs; - fs = Cvar_Get ("fs_game", "", CVAR_INIT|CVAR_SYSTEMINFO ); - if (UI_usesUniqueCDKey() && fs && fs->string[0] != 0) { - Com_Memcpy( buf, &cl_cdkey[16], 16); - buf[16] = 0; - } else { - Com_Memcpy( buf, cl_cdkey, 16); - buf[16] = 0; - } -} - - -/* -==================== -CLUI_SetCDKey -==================== -*/ -static void CLUI_SetCDKey( char *buf ) { - cvar_t *fs; - fs = Cvar_Get ("fs_game", "", CVAR_INIT|CVAR_SYSTEMINFO ); - if (UI_usesUniqueCDKey() && fs && fs->string[0] != 0) { - Com_Memcpy( &cl_cdkey[16], buf, 16 ); - cl_cdkey[32] = 0; - // set the flag so the fle will be written at the next opportunity - cvar_modifiedFlags |= CVAR_ARCHIVE; - } else { - Com_Memcpy( cl_cdkey, buf, 16 ); - // set the flag so the fle will be written at the next opportunity - cvar_modifiedFlags |= CVAR_ARCHIVE; - } -} - -/* -==================== -GetConfigString -==================== -*/ -static int GetConfigString(int index, char *buf, int size) -{ - int offset; - - if (index < 0 || index >= MAX_CONFIGSTRINGS) - return qfalse; - - offset = cl.gameState.stringOffsets[index]; - if (!offset) { - if( size ) { - buf[0] = 0; - } - return qfalse; - } - - Q_strncpyz( buf, cl.gameState.stringData+offset, size); - - return qtrue; -} - -/* -==================== -FloatAsInt -==================== -*/ -static int FloatAsInt( float f ) { - int temp; - - *(float *)&temp = f; - - return temp; -} - -/* -==================== -CL_UISystemCalls - -The ui module is making a system call -==================== -*/ -intptr_t CL_UISystemCalls( intptr_t *args ) { - switch( args[0] ) { - case UI_ERROR: - Com_Error( ERR_DROP, "%s", (const char*)VMA(1) ); - return 0; - - case UI_PRINT: - Com_Printf( "%s", (const char*)VMA(1) ); - return 0; - - case UI_MILLISECONDS: - return Sys_Milliseconds(); - - case UI_CVAR_REGISTER: - Cvar_Register( VMA(1), VMA(2), VMA(3), args[4] ); - return 0; - - case UI_CVAR_UPDATE: - Cvar_Update( VMA(1) ); - return 0; - - case UI_CVAR_SET: - Cvar_Set( VMA(1), VMA(2) ); - return 0; - - case UI_CVAR_VARIABLEVALUE: - return FloatAsInt( Cvar_VariableValue( VMA(1) ) ); - - case UI_CVAR_VARIABLESTRINGBUFFER: - Cvar_VariableStringBuffer( VMA(1), VMA(2), args[3] ); - return 0; - - case UI_CVAR_SETVALUE: - Cvar_SetValue( VMA(1), VMF(2) ); - return 0; - - case UI_CVAR_RESET: - Cvar_Reset( VMA(1) ); - return 0; - - case UI_CVAR_CREATE: - Cvar_Get( VMA(1), VMA(2), args[3] ); - return 0; - - case UI_CVAR_INFOSTRINGBUFFER: - Cvar_InfoStringBuffer( args[1], VMA(2), args[3] ); - return 0; - - case UI_ARGC: - return Cmd_Argc(); - - case UI_ARGV: - Cmd_ArgvBuffer( args[1], VMA(2), args[3] ); - return 0; - - case UI_CMD_EXECUTETEXT: - Cbuf_ExecuteText( args[1], VMA(2) ); - return 0; - - case UI_FS_FOPENFILE: - return FS_FOpenFileByMode( VMA(1), VMA(2), args[3] ); - - case UI_FS_READ: - FS_Read2( VMA(1), args[2], args[3] ); - return 0; - - case UI_FS_WRITE: - FS_Write( VMA(1), args[2], args[3] ); - return 0; - - case UI_FS_FCLOSEFILE: - FS_FCloseFile( args[1] ); - return 0; - - case UI_FS_GETFILELIST: - return FS_GetFileList( VMA(1), VMA(2), VMA(3), args[4] ); - - case UI_FS_SEEK: - return FS_Seek( args[1], args[2], args[3] ); - - case UI_R_REGISTERMODEL: - return re.RegisterModel( VMA(1) ); - - case UI_R_REGISTERSHADER: - return re.RegisterShader( VMA(1) ); - - case UI_R_REGISTERSHADERNOMIP: - return re.RegisterShaderNoMip( VMA(1) ); - - case UI_R_CLEARSCENE: - re.ClearScene(); - return 0; - - case UI_R_ADDREFENTITYTOSCENE: - re.AddRefEntityToScene( VMA(1) ); - return 0; - - case UI_R_ADDPOLYTOSCENE: - re.AddPolyToScene( args[1], args[2], VMA(3), 1 ); - return 0; - - case UI_R_ADDLIGHTTOSCENE: - re.AddLightToScene( VMA(1), VMF(2), VMF(3), VMF(4), VMF(5) ); - return 0; - - case UI_R_RENDERSCENE: - re.RenderScene( VMA(1) ); - return 0; - - case UI_R_SETCOLOR: - re.SetColor( VMA(1) ); - return 0; - - case UI_R_DRAWSTRETCHPIC: - re.DrawStretchPic( VMF(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), VMF(7), VMF(8), args[9] ); - return 0; - - case UI_R_MODELBOUNDS: - re.ModelBounds( args[1], VMA(2), VMA(3) ); - return 0; - - case UI_UPDATESCREEN: - SCR_UpdateScreen(); - return 0; - - case UI_S_REGISTERSOUND: - return S_RegisterSound( VMA(1), args[2] ); - - case UI_S_STARTLOCALSOUND: - S_StartLocalSound( args[1], args[2] ); - return 0; - - case UI_KEY_KEYNUMTOSTRINGBUF: - Key_KeynumToStringBuf( args[1], VMA(2), args[3] ); - return 0; - - case UI_KEY_GETBINDINGBUF: - Key_GetBindingBuf( args[1], VMA(2), args[3] ); - return 0; - - case UI_KEY_SETBINDING: - Key_SetBinding( args[1], VMA(2) ); - return 0; - - case UI_KEY_ISDOWN: - return Key_IsDown( args[1] ); - - case UI_KEY_GETOVERSTRIKEMODE: - return Key_GetOverstrikeMode(); - - case UI_KEY_SETOVERSTRIKEMODE: - Key_SetOverstrikeMode( args[1] ); - return 0; - - case UI_KEY_CLEARSTATES: - Key_ClearStates(); - return 0; - - case UI_KEY_GETCATCHER: - return Key_GetCatcher(); - - case UI_KEY_SETCATCHER: - // Don't allow the ui module to close the console - Key_SetCatcher( args[1] | ( Key_GetCatcher( ) & KEYCATCH_CONSOLE ) ); - return 0; - - case UI_GETCLIPBOARDDATA: - CL_GetClipboardData( VMA(1), args[2] ); - return 0; - - case UI_GETCLIENTSTATE: - GetClientState( VMA(1) ); - return 0; - - case UI_GETGLCONFIG: - CL_GetGlconfig( VMA(1) ); - return 0; - - case UI_GETCONFIGSTRING: - return GetConfigString( args[1], VMA(2), args[3] ); - - case UI_LAN_LOADCACHEDSERVERS: - LAN_LoadCachedServers(); - return 0; - - case UI_LAN_SAVECACHEDSERVERS: - LAN_SaveServersToCache(); - return 0; - - case UI_LAN_ADDSERVER: - return LAN_AddServer(args[1], VMA(2), VMA(3)); - - case UI_LAN_REMOVESERVER: - LAN_RemoveServer(args[1], VMA(2)); - return 0; - - case UI_LAN_GETPINGQUEUECOUNT: - return LAN_GetPingQueueCount(); - - case UI_LAN_CLEARPING: - LAN_ClearPing( args[1] ); - return 0; - - case UI_LAN_GETPING: - LAN_GetPing( args[1], VMA(2), args[3], VMA(4) ); - return 0; - - case UI_LAN_GETPINGINFO: - LAN_GetPingInfo( args[1], VMA(2), args[3] ); - return 0; - - case UI_LAN_GETSERVERCOUNT: - return LAN_GetServerCount(args[1]); - - case UI_LAN_GETSERVERADDRESSSTRING: - LAN_GetServerAddressString( args[1], args[2], VMA(3), args[4] ); - return 0; - - case UI_LAN_GETSERVERINFO: - LAN_GetServerInfo( args[1], args[2], VMA(3), args[4] ); - return 0; - - case UI_LAN_GETSERVERPING: - return LAN_GetServerPing( args[1], args[2] ); - - case UI_LAN_MARKSERVERVISIBLE: - LAN_MarkServerVisible( args[1], args[2], args[3] ); - return 0; - - case UI_LAN_SERVERISVISIBLE: - return LAN_ServerIsVisible( args[1], args[2] ); - - case UI_LAN_UPDATEVISIBLEPINGS: - return LAN_UpdateVisiblePings( args[1] ); - - case UI_LAN_RESETPINGS: - LAN_ResetPings( args[1] ); - return 0; - - case UI_LAN_SERVERSTATUS: - return LAN_GetServerStatus( VMA(1), VMA(2), args[3] ); - - case UI_LAN_COMPARESERVERS: - return LAN_CompareServers( args[1], args[2], args[3], args[4], args[5] ); - - case UI_MEMORY_REMAINING: - return Hunk_MemoryRemaining(); - - case UI_GET_CDKEY: - CLUI_GetCDKey( VMA(1), args[2] ); - return 0; - - case UI_SET_CDKEY: - CLUI_SetCDKey( VMA(1) ); - return 0; - - case UI_SET_PBCLSTATUS: - return 0; - - case UI_R_REGISTERFONT: - re.RegisterFont( VMA(1), args[2], VMA(3)); - return 0; - - case UI_MEMSET: - Com_Memset( VMA(1), args[2], args[3] ); - return 0; - - case UI_MEMCPY: - Com_Memcpy( VMA(1), VMA(2), args[3] ); - return 0; - - case UI_STRNCPY: - strncpy( VMA(1), VMA(2), args[3] ); - return args[1]; - - case UI_SIN: - return FloatAsInt( sin( VMF(1) ) ); - - case UI_COS: - return FloatAsInt( cos( VMF(1) ) ); - - case UI_ATAN2: - return FloatAsInt( atan2( VMF(1), VMF(2) ) ); - - case UI_SQRT: - return FloatAsInt( sqrt( VMF(1) ) ); - - case UI_FLOOR: - return FloatAsInt( floor( VMF(1) ) ); - - case UI_CEIL: - return FloatAsInt( ceil( VMF(1) ) ); - - case UI_PC_ADD_GLOBAL_DEFINE: - return botlib_export->PC_AddGlobalDefine( VMA(1) ); - case UI_PC_LOAD_SOURCE: - return botlib_export->PC_LoadSourceHandle( VMA(1) ); - case UI_PC_FREE_SOURCE: - return botlib_export->PC_FreeSourceHandle( args[1] ); - case UI_PC_READ_TOKEN: - return botlib_export->PC_ReadTokenHandle( args[1], VMA(2) ); - case UI_PC_SOURCE_FILE_AND_LINE: - return botlib_export->PC_SourceFileAndLine( args[1], VMA(2), VMA(3) ); - - case UI_S_STOPBACKGROUNDTRACK: - S_StopBackgroundTrack(); - return 0; - case UI_S_STARTBACKGROUNDTRACK: - S_StartBackgroundTrack( VMA(1), VMA(2)); - return 0; - - case UI_REAL_TIME: - return Com_RealTime( VMA(1) ); - - case UI_CIN_PLAYCINEMATIC: - Com_DPrintf("UI_CIN_PlayCinematic\n"); - return CIN_PlayCinematic(VMA(1), args[2], args[3], args[4], args[5], args[6]); - - case UI_CIN_STOPCINEMATIC: - return CIN_StopCinematic(args[1]); - - case UI_CIN_RUNCINEMATIC: - return CIN_RunCinematic(args[1]); - - case UI_CIN_DRAWCINEMATIC: - CIN_DrawCinematic(args[1]); - return 0; - - case UI_CIN_SETEXTENTS: - CIN_SetExtents(args[1], args[2], args[3], args[4], args[5]); - return 0; - - case UI_VERIFY_CDKEY: - return CL_CDKeyValidate(VMA(1), VMA(2)); - - // IneQuation - case UI_R_TEXT_WIDTH: - return re.Text_Width(VMA(1), VMA(2), args[3], args[4]); - case UI_R_TEXT_HEIGHT: - return re.Text_Height(VMA(1), VMA(2), args[3], args[4]); - case UI_R_TEXT_PAINT: - re.Text_Paint(VMA(1), VMF(2), VMF(3), VMF(4), VMF(5), VMA(6), VMF(7), args[8], args[9], args[10]); - return 0; - case UI_R_TEXT_PAINTCHAR: - re.Text_PaintChar(VMA(1), VMF(2), VMF(3), VMF(4), args[5], args[6]); - return 0; - - // su44 - case UI_TIKI_REGISTERMODEL: - return TIKI_RegisterModel(VMA(1)); - case UI_TIKI_GETBONES: - return TIKI_GetBones(VMA(1)); - case UI_TIKI_SETCHANNELS: - TIKI_SetChannels(VMA(1),args[2],VMF(3),VMF(4),VMA(5)); - return 0; - case UI_TIKI_APPENDFRAMEBOUNDSANDRADIUS: - TIKI_AppendFrameBoundsAndRadius(VMA(1),args[2],VMF(3),(void*)args[4],(void*)args[5]); - return 0; - case UI_TIKI_ANIMATE: - TIKI_Animate(VMA(1),VMA(2)); - return 0; - case UI_TIKI_GETBONENAMEINDEX: - return TIKI_RegisterBoneName(args[1]); - case UI_GETSHADERNAME: - return re.GetShaderName(args[1]); - - - - default: - Com_Error( ERR_DROP, "Bad UI system trap: %ld", (long int) args[0] ); - - } - - return 0; -} - -/* -==================== -CL_ShutdownUI -==================== -*/ -void CL_ShutdownUI( void ) { - Key_SetCatcher( Key_GetCatcher( ) & ~KEYCATCH_UI ); - cls.uiStarted = qfalse; - if ( !uivm ) { - return; - } - VM_Call( uivm, UI_SHUTDOWN ); - VM_Free( uivm ); - uivm = NULL; -} - -/* -==================== -CL_InitializeUI -==================== -*/ -#define UI_OLD_API_VERSION 4 - -void CL_InitializeUI( void ) { - int v; - vmInterpret_t interpret; - - // load the dll or bytecode - if ( cl_connectedToPureServer != 0 ) { - // if sv_pure is set we only allow qvms to be loaded - interpret = VMI_COMPILED; - } - else { - interpret = Cvar_VariableValue( "vm_ui" ); - } - - uivm = VM_Create( "ui", CL_UISystemCalls, interpret ); - - if ( !uivm ) { - Com_Error( ERR_FATAL, "VM_Create on UI failed" ); - } - - // sanity check - v = VM_Call( uivm, UI_GETAPIVERSION ); - if (v == UI_OLD_API_VERSION) { -// Com_Printf(S_COLOR_YELLOW "WARNING: loading old Quake III Arena User Interface version %d\n", v ); - // init for this gamestate - VM_Call( uivm, UI_INIT, (cls.state >= CA_AUTHORIZING && cls.state < CA_ACTIVE)); - } - else if (v != UI_API_VERSION) { - Com_Error( ERR_DROP, "User Interface is version %d, expected %d", v, UI_API_VERSION ); - cls.uiStarted = qfalse; - } - else { - // init for this gamestate - VM_Call( uivm, UI_INIT, (cls.state >= CA_AUTHORIZING && cls.state < CA_ACTIVE) ); - } - - // reset any CVAR_CHEAT cvars registered by ui - if ( !clc.demoplaying && !cl_connectedToCheatServer ) - Cvar_SetCheatState(); -} - -qboolean UI_usesUniqueCDKey( void ) { - if (uivm) { - return (VM_Call( uivm, UI_HASUNIQUECDKEY) == qtrue); - } else { - return qfalse; - } -} - -/* -==================== -UI_GameCommand - -See if the current console command is claimed by the ui -==================== -*/ -qboolean UI_GameCommand( void ) { - if ( !uivm ) { - return qfalse; - } - - return VM_Call( uivm, UI_CONSOLE_COMMAND, cls.realtime ); -} diff --git a/code/client/cl_ui.cpp b/code/client/cl_ui.cpp index caf3aab5..d6422ecd 100644 --- a/code/client/cl_ui.cpp +++ b/code/client/cl_ui.cpp @@ -22,15 +22,13 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "client.h" -#include "../botlib/botlib.h" #include "../server/server.h" #include "../renderercommon/tr_common.h" +#include "tiki.h" #include #include "cl_ui.h" -extern botlib_export_t *botlib_export; - typedef struct { float fadetime; float starttime; @@ -4557,7 +4555,7 @@ UI_SetScoreBoardItem void UI_SetScoreBoardItem( int iItemNumber, const char *pszData1, const char *pszData2, const char *pszData3, const char *pszData4, const char *pszData5, const char *pszData6, const char *pszData7, const char *pszData8, - vec4_t pTextColor, vec4_t pBackColor, qboolean bIsHeader ) + const vec4_t pTextColor, const vec4_t pBackColor, qboolean bIsHeader ) { int i; float x, y, w, h; @@ -5420,7 +5418,7 @@ UI_BeginLoadResource ==================== */ void UI_BeginLoadResource( void ) { - uint64_t time = rdtsc(); + uint64_t time = __rdtsc(); startCountHigh = time >> 32; startCountLow = time; diff --git a/code/client/cl_ui.h b/code/client/cl_ui.h index 94eb2424..525cbf1e 100644 --- a/code/client/cl_ui.h +++ b/code/client/cl_ui.h @@ -72,7 +72,7 @@ void UI_HideScoreboard_f( void ); void UI_SetScoreBoardItem( int iItemNumber, const char *pszData1, const char *pszData2, const char *pszData3, const char *pszData4, const char *pszData5, const char *pszData6, const char *pszData7, const char *pszData8, - vec4_t pTextColor, vec4_t pBackColor, qboolean bIsHeader ); + const vec4_t pTextColor, const vec4_t pBackColor, qboolean bIsHeader ); void UI_DeleteScoreBoardItems( int iMaxIndex ); // diff --git a/code/client/cl_uiview3d.cpp b/code/client/cl_uiview3d.cpp index a16eea0c..4fa03517 100644 --- a/code/client/cl_uiview3d.cpp +++ b/code/client/cl_uiview3d.cpp @@ -21,7 +21,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "cl_ui.h" -#include "cl_screen.h" CLASS_DECLARATION( UIWidget, View3D, NULL ) { diff --git a/code/client/snd_dma_new.cpp b/code/client/snd_dma_new.cpp index 29713121..02f76921 100644 --- a/code/client/snd_dma_new.cpp +++ b/code/client/snd_dma_new.cpp @@ -207,13 +207,13 @@ void S_ChannelSetup( void ) { Com_Memset( s_channels, 0, sizeof( s_channels ) ); p = s_channels;; - q = p + MAX_CHANNELS; + q = p + MAX_SOUNDCHANNELS; while( --q > p ) { *( channel_t ** )q = q - 1; } *( channel_t ** )q = NULL; - freelist = p + MAX_CHANNELS - 1; + freelist = p + MAX_SOUNDCHANNELS - 1; Com_DPrintf( "Channel memory manager started\n" ); } @@ -599,7 +599,7 @@ static void S_Base_StartSoundEx( const vec3_t origin, int entityNum, int entchan ch = s_channels; inplay = 0; - for( i = 0; i < MAX_CHANNELS; i++, ch++ ) { + for( i = 0; i < MAX_SOUNDCHANNELS; i++, ch++ ) { if( ch->entnum == entityNum && ch->thesfx == sfx ) { if( time - ch->allocTime < 50 ) { // if (Cvar_VariableValue( "cg_showmiss" )) { @@ -623,7 +623,7 @@ static void S_Base_StartSoundEx( const vec3_t origin, int entityNum, int entchan oldest = sfx->lastTimeUsed; chosen = -1; - for( i = 0; i < MAX_CHANNELS; i++, ch++ ) { + for( i = 0; i < MAX_SOUNDCHANNELS; i++, ch++ ) { if( ch->entnum != listener_number && ch->entnum == entityNum && ch->allocTimeentchannel != CHAN_ANNOUNCER ) { oldest = ch->allocTime; chosen = i; @@ -631,7 +631,7 @@ static void S_Base_StartSoundEx( const vec3_t origin, int entityNum, int entchan } if( chosen == -1 ) { ch = s_channels; - for( i = 0; i < MAX_CHANNELS; i++, ch++ ) { + for( i = 0; i < MAX_SOUNDCHANNELS; i++, ch++ ) { if( ch->entnum != listener_number && ch->allocTimeentchannel != CHAN_ANNOUNCER ) { oldest = ch->allocTime; chosen = i; @@ -640,7 +640,7 @@ static void S_Base_StartSoundEx( const vec3_t origin, int entityNum, int entchan if( chosen == -1 ) { ch = s_channels; if( ch->entnum == listener_number ) { - for( i = 0; i < MAX_CHANNELS; i++, ch++ ) { + for( i = 0; i < MAX_SOUNDCHANNELS; i++, ch++ ) { if( ch->allocTimeallocTime; chosen = i; @@ -726,7 +726,7 @@ void S_Base_ClearSoundBuffer( void ) { // stop looping sounds Com_Memset( loopSounds, 0, MAX_GENTITIES*sizeof( loopSound_t ) ); - Com_Memset( loop_channels, 0, MAX_CHANNELS*sizeof( channel_t ) ); + Com_Memset( loop_channels, 0, MAX_SOUNDCHANNELS*sizeof( channel_t ) ); numLoopChannels = 0; S_ChannelSetup(); @@ -972,7 +972,7 @@ void S_AddLoopSounds( void ) { ch->oldDopplerScale = loop->oldDopplerScale; ch->fullVolume = qfalse; numLoopChannels++; - if( numLoopChannels == MAX_CHANNELS ) { + if( numLoopChannels == MAX_SOUNDCHANNELS ) { return; } } @@ -1176,7 +1176,7 @@ void S_Base_Respatialize( int entityNum, const vec3_t head, vec3_t axis[ 3 ], in // update spatialization for dynamic sounds ch = s_channels; - for( i = 0; i < MAX_CHANNELS; i++, ch++ ) { + for( i = 0; i < MAX_SOUNDCHANNELS; i++, ch++ ) { if( !ch->thesfx ) { continue; } @@ -1217,7 +1217,7 @@ qboolean S_ScanChannelStarts( void ) { newSamples = qfalse; ch = s_channels; - for( i = 0; ithesfx ) { continue; } @@ -1262,7 +1262,7 @@ void S_Base_Update( void ) { if( s_show->integer == 2 ) { total = 0; ch = s_channels; - for( i = 0; ithesfx && ( ch->leftvol || ch->rightvol ) ) { Com_Printf( "%d %d %s\n", ch->leftvol, ch->rightvol, ch->thesfx->soundName ); total++; diff --git a/code/client/snd_mix.c b/code/client/snd_mix.c index 3754dd4a..d1c11d56 100644 --- a/code/client/snd_mix.c +++ b/code/client/snd_mix.c @@ -716,7 +716,7 @@ void S_PaintChannels( int endtime ) { // paint in the channels. ch = s_channels; - for( i = 0; i < MAX_CHANNELS; i++, ch++ ) { + for( i = 0; i < MAX_SOUNDCHANNELS; i++, ch++ ) { if( !ch->thesfx || ( ch->leftvol<0.25 && ch->rightvol<0.25 ) ) { continue; } diff --git a/code/null/null_input.c b/code/null/null_input.c index c6520054..b03b6241 100644 --- a/code/null/null_input.c +++ b/code/null/null_input.c @@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "../client/client.h" -void IN_Init( void ) { +void IN_Init( void *windowData ) { } void IN_Restart( void ) { diff --git a/code/qcommon/cmd.c b/code/qcommon/cmd.c index b427c16e..82406c2f 100644 --- a/code/qcommon/cmd.c +++ b/code/qcommon/cmd.c @@ -148,7 +148,7 @@ void Cbuf_InsertText( const char *text ) { Cbuf_ExecuteText ============ */ -void Cbuf_ExecuteText (int exec_when, const char *text) +void Cbuf_ExecuteText (cbufExec_t exec_when, const char *text) { switch (exec_when) { diff --git a/code/qcommon/files.cpp b/code/qcommon/files.cpp index 39dcc5bb..437ba98a 100644 --- a/code/qcommon/files.cpp +++ b/code/qcommon/files.cpp @@ -1879,7 +1879,7 @@ FS_WriteFile Filename are reletive to the quake search path ============ */ -size_t FS_WriteFile( const char *qpath, const void *buffer, size_t size ) { +int FS_WriteFile( const char *qpath, const void *buffer, int size ) { fileHandle_t f; size_t len; @@ -1911,7 +1911,7 @@ FS_WriteTextFile Filename are reletive to the quake search path ============ */ -void FS_WriteTextFile( const char *qpath, const void *buffer, size_t size ) { +void FS_WriteTextFile( const char *qpath, const void *buffer, int size ) { fileHandle_t f; f = FS_FOpenTextFileWrite( qpath ); diff --git a/code/qcommon/msg.cpp b/code/qcommon/msg.cpp index 11f42217..d8f7ea30 100644 --- a/code/qcommon/msg.cpp +++ b/code/qcommon/msg.cpp @@ -2083,7 +2083,7 @@ Can go from either a baseline or a previous packet_entity extern cvar_t *cl_shownet; void MSG_ReadDeltaEntity( msg_t *msg, entityState_t *from, entityState_t *to, - int number) { + int number, float frameTime) { int i, lc; int numFields; netField_t *field; diff --git a/code/qcommon/qcommon.h b/code/qcommon/qcommon.h index fc2df8d7..4cfb8206 100644 --- a/code/qcommon/qcommon.h +++ b/code/qcommon/qcommon.h @@ -431,7 +431,7 @@ void Cbuf_Init (void); void Cbuf_AddText( const char *text ); // Adds command text at the end of the buffer, does NOT add a final \n -void Cbuf_ExecuteText( int exec_when, const char *text ); +void Cbuf_ExecuteText(cbufExec_t exec_when, const char *text ); // this can be used in place of either Cbuf_AddText or Cbuf_InsertText void Cbuf_Execute (int msec); @@ -704,10 +704,10 @@ void FS_FreeFile( void *buffer ); const char *FS_PrepFileWrite( const char *filename ); // prepares the file to be written -size_t FS_WriteFile( const char *qpath, const void *buffer, size_t size ); +int FS_WriteFile( const char *qpath, const void *buffer, int size ); // writes a complete file, creating any subdirectories needed -void FS_WriteTextFile( const char *qpath, const void *buffer, size_t size ); +void FS_WriteTextFile( const char *qpath, const void *buffer, int size ); // writes a complete text file, creating any subdirectories needed int FS_filelength( fileHandle_t f ); @@ -1088,7 +1088,7 @@ qboolean SV_GameCommand( void ); // // input interface // -void IN_Init(); +void IN_Init(void *windowData); void IN_Frame(void); void IN_Shutdown(void); void IN_Restart(void); diff --git a/code/qcommon/script.cpp b/code/qcommon/script.cpp index 9ac4c67f..a78b0006 100644 --- a/code/qcommon/script.cpp +++ b/code/qcommon/script.cpp @@ -45,7 +45,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #elif defined(CGAME_DLL) #define FILE_FS_FreeFile cgi.FS_FreeFile -#define FILE_FS_ReadFile(a, b) cgi.FS_ReadFile(a, b) +#define FILE_FS_ReadFile(a, b) cgi.FS_ReadFile(a, b, qtrue) #define FILE_Malloc cgi.Malloc #define FILE_Free cgi.Free #define FILE_Error cgi.Error diff --git a/code/renderercommon/tr_public.h b/code/renderercommon/tr_public.h index 27bce218..a3debf17 100644 --- a/code/renderercommon/tr_public.h +++ b/code/renderercommon/tr_public.h @@ -118,8 +118,10 @@ typedef struct { int (*MarkFragments)( int numPoints, const vec3_t *points, const vec3_t projection, int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer, float fRadiusSquared ); - int (*MarkFragmentsForInlineModel)( clipHandle_t bmodel, vec3_t angles, vec3_t origin, - int numPoints, vec3_t *points, vec3_t projection, int maxPoints, float *pointBuffer, int maxFragments, markFragment_t *fragmentBuffer, float radiusSquared ); + int (*MarkFragmentsForInlineModel)( clipHandle_t bmodel, vec3_t vAngles, vec3_t vOrigin, + int numPoints, const vec3_t *points, const vec3_t projection, + int maxPoints, vec3_t pointBuffer, + int maxFragments, markFragment_t *fragmentBuffer, float fRadiusSquared ); void ( *GetInlineModelBounds )( int index, vec3_t mins, vec3_t maxs ); void ( *GetLightingForDecal )( vec3_t light, vec3_t facing, vec3_t origin ); @@ -190,12 +192,12 @@ typedef struct { // stack based memory allocation for per-level things that // won't be freed void (*Hunk_Clear )( void ); - void *(*Hunk_Alloc)( int size ); - void *(*Hunk_AllocateTempMemory)( int size ); + void *(*Hunk_Alloc)(size_t size ); + void *(*Hunk_AllocateTempMemory)(size_t size ); void (*Hunk_FreeTempMemory)( void *block ); // dynamic memory allocator for things that need to be freed - void *(*Malloc)( size_t bytes ); + void *(*Malloc)(size_t bytes ); void (*Free)( void *buf ); void (*Clear)( void ); @@ -209,7 +211,7 @@ typedef struct { int (*Cmd_Argc) (void); char *(*Cmd_Argv) (int i); - void (*Cmd_ExecuteText) (int exec_when, const char *text); + void (*Cmd_ExecuteText) (cbufExec_t exec_when, const char *text); // visualization for debugging collision detection void (*CM_DrawDebugSurface)( void (*drawPoly)(int color, int numPoints, float *points) ); @@ -217,7 +219,7 @@ typedef struct { // a -1 return means the file does not exist // NULL can be passed for buf to just determine existance int (*FS_FOpenFile)( const char *filename, fileHandle_t *file, qboolean uniqueFILE, qboolean quiet ); - int (*FS_Read)( void *buffer, int len, fileHandle_t f ); + size_t (*FS_Read)( void *buffer, size_t len, fileHandle_t f ); void (*FS_CloseFile)( fileHandle_t f ); int (*FS_Seek)( fileHandle_t f, long offset, fsOrigin_t origin ); int (*FS_FileIsInPAK)( const char *filename, int *pChecksum ); @@ -261,7 +263,7 @@ typedef struct { orientation_t (*TIKI_OrientationInternal)( dtiki_t *tiki, int entnum, int tagnum, float scale ); qboolean (*TIKI_IsOnGroundInternal) (dtiki_t *tiki, int entnum, int tagnum, float threshold ); void (*TIKI_SetPoseInternal)( void *skeletor, const frameInfo_t *frameInfo, int *bone_tag, vec4_t *bone_quat, float actionWeight ); - void *(*TIKI_Alloc)( int size ); + void *(*TIKI_Alloc)(size_t size ); float (*GetRadiusInternal)( dtiki_t *tiki, int entnum, float scale ); float (*GetCentroidRadiusInternal)( dtiki_t *tiki, int entnum, float scale, float *centroid ); void (*GetFrameInternal)( dtiki_t *tiki, int entnum, skelAnimFrame_t *newFrame ); diff --git a/code/uilib/uimenu.h b/code/uilib/uimenu.h index 111804dc..f11001d8 100644 --- a/code/uilib/uimenu.h +++ b/code/uilib/uimenu.h @@ -23,6 +23,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #ifndef __UIMENU_H__ #define __UIMENU_H__ +#include "listener.h" +#include "stack.h" + class Menu : public Listener { qboolean m_fullscreen; int m_vidmode;