Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into connectionless_packet
Browse files Browse the repository at this point in the history
  • Loading branch information
mbasaglia committed Nov 10, 2015
2 parents 4fdc624 + d57bf9b commit c211fc4
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 175 deletions.
156 changes: 6 additions & 150 deletions daemon/src/engine/client/cl_cgame.cpp
Expand Up @@ -743,133 +743,6 @@ void Key_SetCatcher( int catcher )
} }
} }


/*
====================
CL_UpdateLevelHunkUsage
This updates the "hunkusage.dat" file with the current map and its hunk usage count
This is used for level loading, so we can show a percentage bar dependent on the amount
of hunk memory allocated so far
This will be slightly inaccurate if some settings like sound quality are changed, but these
things should only account for a small variation (hopefully)
====================
*/
void CL_UpdateLevelHunkUsage()
{
int handle;
const char *memlistfile = "hunkusage.dat";
char *buf, *outbuf;
const char *buftrav;
char *outbuftrav;
char *token;
char outstr[ 256 ];
int len, memusage;

memusage = Cvar_VariableIntegerValue( "com_hunkused" ) + Cvar_VariableIntegerValue( "hunk_soundadjust" );

len = FS_FOpenFileRead( memlistfile, &handle, false );

if ( len >= 0 )
{
// the file exists, so read it in, strip out the current entry for this map, and save it out, so we can append the new value
buf = ( char * ) Z_Malloc( len + 1 );
outbuf = ( char * ) Z_Malloc( len + 1 );

FS_Read( ( void * ) buf, len, handle );
FS_FCloseFile( handle );

// now parse the file, filtering out the current map
buftrav = buf;
outbuftrav = outbuf;
outbuftrav[ 0 ] = '\0';

while ( ( token = COM_Parse( &buftrav ) ) != nullptr && token[ 0 ] )
{
if ( !Q_stricmp( token, cl.mapname ) )
{
// found a match
token = COM_Parse( &buftrav ); // read the size

if ( token && token[ 0 ] )
{
if ( atoi( token ) == memusage )
{
// if it is the same, abort this process
Z_Free( buf );
Z_Free( outbuf );
return;
}
}
}
else
{
// send it to the outbuf
Q_strcat( outbuftrav, len + 1, token );
Q_strcat( outbuftrav, len + 1, " " );
token = COM_Parse( &buftrav ); // read the size

if ( token && token[ 0 ] )
{
Q_strcat( outbuftrav, len + 1, token );
Q_strcat( outbuftrav, len + 1, "\n" );
}
else
{
Z_Free( buf );
Z_Free( outbuf );
Com_Error( ERR_DROP, "hunkusage.dat file is corrupt" );
}
}
}

handle = FS_FOpenFileWrite( memlistfile );

if ( handle < 0 )
{
Z_Free( buf );
Z_Free( outbuf );
Com_Error( ERR_DROP, "cannot create %s", memlistfile );
}

// input file is parsed, now output to the new file
len = strlen( outbuf );

if ( FS_Write( ( void * ) outbuf, len, handle ) != len )
{
Z_Free( buf );
Z_Free( outbuf );
Com_Error( ERR_DROP, "cannot write to %s", memlistfile );
}

FS_FCloseFile( handle );

Z_Free( buf );
Z_Free( outbuf );
}

// now append the current map to the current file
handle = FS_FOpenFileAppend( memlistfile );

if ( handle == 0 )
{
Com_Error( ERR_DROP, "cannot write to hunkusage.dat, check disk full" );
}

Com_sprintf( outstr, sizeof( outstr ), "%s %i\n", cl.mapname, memusage );
FS_Write( outstr, strlen( outstr ), handle );
FS_FCloseFile( handle );

// now just open it and close it, so it gets copied to the pak dir
len = FS_FOpenFileRead( memlistfile, &handle, false );

if ( len >= 0 )
{
FS_FCloseFile( handle );
}
}

/* /*
==================== ====================
CL_InitCGame CL_InitCGame
Expand Down Expand Up @@ -911,29 +784,12 @@ void CL_InitCGame()
// on the card even if the driver does deferred loading // on the card even if the driver does deferred loading
re.EndRegistration(); re.EndRegistration();


// Ridah, update the memory usage file
CL_UpdateLevelHunkUsage();

// Cause any input while loading to be dropped and forget what's pressed // Cause any input while loading to be dropped and forget what's pressed
IN_DropInputsForFrame(); IN_DropInputsForFrame();
CL_ClearKeys(); CL_ClearKeys();
Key_ClearStates(); Key_ClearStates();
} }


void CL_InitCGameCVars()
{/* TODO I don't understand that
vm_t *cgv_vm = VM_Create( "cgame", CL_CgameSystemCalls, (vmInterpret_t) Cvar_VariableIntegerValue( "vm_cgame" ) );
if ( !cgv_vm )
{
Com_Error( ERR_DROP, "VM_Create on cgame failed" );
}
VM_Call( cgv_vm, CG_INIT_CVARS );
VM_Free( cgv_vm );*/
}

/* /*
===================== =====================
CL_CGameRendering CL_CGameRendering
Expand Down Expand Up @@ -1551,11 +1407,11 @@ void CGameVM::QVMSyscall(int index, Util::Reader& reader, IPC::Channel& channel)


// All sounds // All sounds


case CG_S_REGISTERSOUND: case CG_S_REGISTERSOUND:
IPC::HandleMsg<Audio::RegisterSoundMsg>(channel, std::move(reader), [this] (const std::string& sample, int& handle) { IPC::HandleMsg<Audio::RegisterSoundMsg>(channel, std::move(reader), [this] (const std::string& sample, int& handle) {
handle = Audio::RegisterSFX(sample.c_str()); handle = Audio::RegisterSFX(sample.c_str());
}); });
break; break;


// All renderer // All renderer


Expand Down Expand Up @@ -1747,7 +1603,7 @@ void CGameVM::QVMSyscall(int index, Util::Reader& reader, IPC::Channel& channel)
CL_ClearCmdButtons(); CL_ClearCmdButtons();
}); });
break; break;
//
case CG_KEY_CLEARSTATES: case CG_KEY_CLEARSTATES:
IPC::HandleMsg<Key::ClearStatesMsg>(channel, std::move(reader), [this] { IPC::HandleMsg<Key::ClearStatesMsg>(channel, std::move(reader), [this] {
Key_ClearStates(); Key_ClearStates();
Expand Down
10 changes: 0 additions & 10 deletions daemon/src/engine/client/cl_main.cpp
Expand Up @@ -1384,7 +1384,6 @@ void CL_ShutdownAll()
cls.uiStarted = false; cls.uiStarted = false;
cls.cgameStarted = false; cls.cgameStarted = false;
cls.rendererStarted = false; cls.rendererStarted = false;
cls.cgameCVarsRegistered = false;
cls.soundRegistered = false; cls.soundRegistered = false;


// Gordon: stop recording on map change etc, demos aren't valid over map changes anyway // Gordon: stop recording on map change etc, demos aren't valid over map changes anyway
Expand Down Expand Up @@ -2124,7 +2123,6 @@ void CL_Vid_Restart_f()
cls.rendererStarted = false; cls.rendererStarted = false;
cls.uiStarted = false; cls.uiStarted = false;
cls.cgameStarted = false; cls.cgameStarted = false;
cls.cgameCVarsRegistered = false;
cls.soundRegistered = false; cls.soundRegistered = false;


// unpause so the cgame definitely gets a snapshot and renders a frame // unpause so the cgame definitely gets a snapshot and renders a frame
Expand Down Expand Up @@ -2153,7 +2151,6 @@ void CL_Vid_Restart_f()
if ( cls.state > CA_CONNECTED && cls.state != CA_CINEMATIC ) if ( cls.state > CA_CONNECTED && cls.state != CA_CINEMATIC )
{ {
cls.cgameStarted = true; cls.cgameStarted = true;
cls.cgameCVarsRegistered = true;
CL_InitCGame(); CL_InitCGame();
} }
} }
Expand Down Expand Up @@ -2403,7 +2400,6 @@ void CL_DownloadsComplete()


// initialize the CGame // initialize the CGame
cls.cgameStarted = true; cls.cgameStarted = true;
cls.cgameCVarsRegistered = true;
CL_InitCGame(); CL_InitCGame();


CL_WritePacket(); CL_WritePacket();
Expand Down Expand Up @@ -3704,12 +3700,6 @@ void CL_StartHunkUsers()
//S_BeginRegistration(); //S_BeginRegistration();
} }


if ( !cls.cgameStarted && !cls.cgameCVarsRegistered )
{
cls.cgameCVarsRegistered = true;
CL_InitCGameCVars();
}

if ( !cls.uiStarted ) if ( !cls.uiStarted )
{ {
cls.uiStarted = true; cls.uiStarted = true;
Expand Down
3 changes: 0 additions & 3 deletions daemon/src/engine/client/client.h
Expand Up @@ -352,8 +352,6 @@ typedef struct
bool uiStarted; bool uiStarted;
bool cgameStarted; bool cgameStarted;


bool cgameCVarsRegistered;

int framecount; int framecount;
int frametime; // msec since last frame int frametime; // msec since last frame


Expand Down Expand Up @@ -849,7 +847,6 @@ void Cin_OGM_Shutdown();
// cl_cgame.c // cl_cgame.c
// //
void CL_InitCGame(); void CL_InitCGame();
void CL_InitCGameCVars();
void CL_ShutdownCGame(); void CL_ShutdownCGame();
void CL_GameCommandHandler(); void CL_GameCommandHandler();
bool CL_GameConsoleText(); bool CL_GameConsoleText();
Expand Down
2 changes: 1 addition & 1 deletion daemon/src/engine/qcommon/q_shared.h
Expand Up @@ -49,7 +49,7 @@ Maryland 20850 USA.
#define PRODUCT_NAME "Unvanquished" #define PRODUCT_NAME "Unvanquished"
#define PRODUCT_NAME_UPPER "UNVANQUISHED" // Case, No spaces #define PRODUCT_NAME_UPPER "UNVANQUISHED" // Case, No spaces
#define PRODUCT_NAME_LOWER "unvanquished" // No case, No spaces #define PRODUCT_NAME_LOWER "unvanquished" // No case, No spaces
#define PRODUCT_VERSION "0.44" #define PRODUCT_VERSION "0.45"


#define ENGINE_NAME "Daemon Engine" #define ENGINE_NAME "Daemon Engine"
#define ENGINE_VERSION PRODUCT_VERSION #define ENGINE_VERSION PRODUCT_VERSION
Expand Down
2 changes: 1 addition & 1 deletion download-pk3.sh
Expand Up @@ -16,7 +16,7 @@ set -e
export LANG=C export LANG=C


# Version of Unvanquished for which this script is built # Version of Unvanquished for which this script is built
VERSION=0.44 VERSION=0.45


# Download from here # Download from here
CDN_URL="http://cdn.unvanquished.net/$VERSION/pkg/" CDN_URL="http://cdn.unvanquished.net/$VERSION/pkg/"
Expand Down
12 changes: 6 additions & 6 deletions libs/libRocket/Include/Rocket/Core/Lua/LuaType.inl
Expand Up @@ -14,7 +14,7 @@
* *
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand All @@ -24,7 +24,7 @@
* THE SOFTWARE. * THE SOFTWARE.
* *
*/ */

//#include "precompiled.h" //#include "precompiled.h"
#include <Rocket/Controls/Controls.h> #include <Rocket/Controls/Controls.h>
#include <Rocket/Core/Core.h> #include <Rocket/Core/Core.h>
Expand Down Expand Up @@ -53,7 +53,7 @@ void LuaType<T>::Register(lua_State* L)
//hide metatable from Lua getmetatable() //hide metatable from Lua getmetatable()
lua_pushvalue(L, methods); //[methods = 1] -> [3] = copy of methods table, including modifications above lua_pushvalue(L, methods); //[methods = 1] -> [3] = copy of methods table, including modifications above
lua_setfield(L, metatable, "__metatable"); //[metatable = 2] -> t[k] = v; t = [2 = ClassMT], k = "__metatable", v = [3 = 1]; pop [3] lua_setfield(L, metatable, "__metatable"); //[metatable = 2] -> t[k] = v; t = [2 = ClassMT], k = "__metatable", v = [3 = 1]; pop [3]

lua_pushcfunction(L, index); //index = cfunction -> [3] = cfunction lua_pushcfunction(L, index); //index = cfunction -> [3] = cfunction
lua_setfield(L, metatable, "__index"); //[metatable = 2] -> t[k] = v; t = [2], k = "__index", v = cfunc; pop [3] lua_setfield(L, metatable, "__index"); //[metatable = 2] -> t[k] = v; t = [2], k = "__index", v = cfunc; pop [3]


Expand Down Expand Up @@ -89,7 +89,7 @@ int LuaType<T>::push(lua_State *L, T* obj, bool gc)
int ud = lua_gettop(L); //ud = 2 int ud = lua_gettop(L); //ud = 2
if(ptrHold != NULL) if(ptrHold != NULL)
{ {
*ptrHold = obj; *ptrHold = obj;
lua_pushvalue(L, mt); // ->[3] = copy of [1] lua_pushvalue(L, mt); // ->[3] = copy of [1]
lua_setmetatable(L, -2); //[-2 = 2] -> [2]'s metatable = [3]; pop [3] lua_setmetatable(L, -2); //[-2 = 2] -> [2]'s metatable = [3]; pop [3]
char name[32]; char name[32];
Expand Down Expand Up @@ -298,7 +298,7 @@ int LuaType<T>::newindex(lua_State* L)
lua_pushvalue(L,1); //userdata at [7] lua_pushvalue(L,1); //userdata at [7]
lua_pushvalue(L,3); //[8] = copy of [3] lua_pushvalue(L,3); //[8] = copy of [3]
if(lua_pcall(L,2,0,0) != 0) //call function, pop 2 off push 0 on if(lua_pcall(L,2,0,0) != 0) //call function, pop 2 off push 0 on
Report(L, String(GetTClassName<T>()).Append(".__newindex for ").Append(lua_tostring(L,2)).Append(": ")); Report(L, String(GetTClassName<T>()).Append(".__newindex for ").Append(lua_tostring(L,2)).Append(": "));
} }
else else
lua_pop(L,1); //not a setter function. lua_pop(L,1); //not a setter function.
Expand All @@ -319,7 +319,7 @@ void LuaType<T>::_regfunctions(lua_State* L, int meta, int methods)
lua_settable(L, methods); // represents t[k] = v, t = [methods] -> pop [2 = closure] to be v, pop [1 = name] to be k lua_settable(L, methods); // represents t[k] = v, t = [methods] -> pop [2 = closure] to be v, pop [1 = name] to be k
} }



lua_getfield(L,methods, "__getters"); // -> table[1] lua_getfield(L,methods, "__getters"); // -> table[1]
if(lua_isnoneornil(L,-1)) if(lua_isnoneornil(L,-1))
{ {
Expand Down
2 changes: 1 addition & 1 deletion macosx/Info.plist
Expand Up @@ -30,6 +30,6 @@
</dict> </dict>
</array> </array>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>0.44</string> <string>0.45</string>
</dict> </dict>
</plist> </plist>
2 changes: 1 addition & 1 deletion main/ui/menu_ingame.rml
Expand Up @@ -113,7 +113,7 @@
<br /> <br />


<blocklink class="rightfloat" onClick='Events.pushevent("exec quit", event)'> Quit game</blocklink> <blocklink class="rightfloat" onClick='Events.pushevent("exec quit", event)'> Quit game</blocklink>
<blocklink class="leftalign fake" style="color: #666666;"> Alpha 0.44 </blocklink> <blocklink class="leftalign fake" style="color: #666666;"> Alpha 0.45 </blocklink>
</sidesection> </sidesection>


</window> </window>
Expand Down
2 changes: 1 addition & 1 deletion main/ui/menu_main.rml
Expand Up @@ -124,7 +124,7 @@
<br /> <br />


<blocklink class="rightfloat" onClick='Events.pushevent("exec quit", event)'> Quit game</blocklink> <blocklink class="rightfloat" onClick='Events.pushevent("exec quit", event)'> Quit game</blocklink>
<blocklink class="leftalign fake" style="color: #666666;"> Alpha 0.44 </blocklink> <blocklink class="leftalign fake" style="color: #666666;"> Alpha 0.45 </blocklink>
</sidesection> </sidesection>


</window> </window>
Expand Down
4 changes: 3 additions & 1 deletion src/cgame/rocket/rocket.cpp
Expand Up @@ -395,6 +395,9 @@ void Rocket_Shutdown()
extern std::map<std::string, RocketDataGrid*> dataSourceMap; extern std::map<std::string, RocketDataGrid*> dataSourceMap;
extern std::queue< RocketEvent_t* > eventQueue; extern std::queue< RocketEvent_t* > eventQueue;


// Shut down Lua before we clean up contexts
Rocket::Core::Lua::Interpreter::Shutdown();

if ( menuContext ) if ( menuContext )
{ {
menuContext->RemoveReference(); menuContext->RemoveReference();
Expand All @@ -407,7 +410,6 @@ void Rocket_Shutdown()
hudContext = nullptr; hudContext = nullptr;
} }


Rocket::Core::Lua::Interpreter::Shutdown();
Rocket::Core::Shutdown(); Rocket::Core::Shutdown();


// Prevent memory leaks // Prevent memory leaks
Expand Down

0 comments on commit c211fc4

Please sign in to comment.