Permalink
Browse files

Merge remote-tracking branch 'origin/master' into connectionless_packet

  • Loading branch information...
mbasaglia committed Nov 10, 2015
2 parents 4fdc624 + d57bf9b commit c211fc4cbcf5d4a58548376bbdb32fefbd440b93
@@ -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
@@ -911,29 +784,12 @@ void CL_InitCGame()
// on the card even if the driver does deferred loading
re.EndRegistration();
// Ridah, update the memory usage file
CL_UpdateLevelHunkUsage();
// Cause any input while loading to be dropped and forget what's pressed
IN_DropInputsForFrame();
CL_ClearKeys();
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
@@ -1551,11 +1407,11 @@ void CGameVM::QVMSyscall(int index, Util::Reader& reader, IPC::Channel& channel)
// All sounds
case CG_S_REGISTERSOUND:
IPC::HandleMsg<Audio::RegisterSoundMsg>(channel, std::move(reader), [this] (const std::string& sample, int& handle) {
handle = Audio::RegisterSFX(sample.c_str());
});
break;
case CG_S_REGISTERSOUND:
IPC::HandleMsg<Audio::RegisterSoundMsg>(channel, std::move(reader), [this] (const std::string& sample, int& handle) {
handle = Audio::RegisterSFX(sample.c_str());
});
break;
// All renderer
@@ -1747,7 +1603,7 @@ void CGameVM::QVMSyscall(int index, Util::Reader& reader, IPC::Channel& channel)
CL_ClearCmdButtons();
});
break;
//
case CG_KEY_CLEARSTATES:
IPC::HandleMsg<Key::ClearStatesMsg>(channel, std::move(reader), [this] {
Key_ClearStates();
@@ -1384,7 +1384,6 @@ void CL_ShutdownAll()
cls.uiStarted = false;
cls.cgameStarted = false;
cls.rendererStarted = false;
cls.cgameCVarsRegistered = false;
cls.soundRegistered = false;
// Gordon: stop recording on map change etc, demos aren't valid over map changes anyway
@@ -2124,7 +2123,6 @@ void CL_Vid_Restart_f()
cls.rendererStarted = false;
cls.uiStarted = false;
cls.cgameStarted = false;
cls.cgameCVarsRegistered = false;
cls.soundRegistered = false;
// unpause so the cgame definitely gets a snapshot and renders a frame
@@ -2153,7 +2151,6 @@ void CL_Vid_Restart_f()
if ( cls.state > CA_CONNECTED && cls.state != CA_CINEMATIC )
{
cls.cgameStarted = true;
cls.cgameCVarsRegistered = true;
CL_InitCGame();
}
}
@@ -2403,7 +2400,6 @@ void CL_DownloadsComplete()
// initialize the CGame
cls.cgameStarted = true;
cls.cgameCVarsRegistered = true;
CL_InitCGame();
CL_WritePacket();
@@ -3704,12 +3700,6 @@ void CL_StartHunkUsers()
//S_BeginRegistration();
}
if ( !cls.cgameStarted && !cls.cgameCVarsRegistered )
{
cls.cgameCVarsRegistered = true;
CL_InitCGameCVars();
}
if ( !cls.uiStarted )
{
cls.uiStarted = true;
@@ -352,8 +352,6 @@ typedef struct
bool uiStarted;
bool cgameStarted;
bool cgameCVarsRegistered;
int framecount;
int frametime; // msec since last frame
@@ -849,7 +847,6 @@ void Cin_OGM_Shutdown();
// cl_cgame.c
//
void CL_InitCGame();
void CL_InitCGameCVars();
void CL_ShutdownCGame();
void CL_GameCommandHandler();
bool CL_GameConsoleText();
@@ -49,7 +49,7 @@ Maryland 20850 USA.
#define PRODUCT_NAME "Unvanquished"
#define PRODUCT_NAME_UPPER "UNVANQUISHED" // 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_VERSION PRODUCT_VERSION
View
@@ -16,7 +16,7 @@ set -e
export LANG=C
# Version of Unvanquished for which this script is built
VERSION=0.44
VERSION=0.45
# Download from here
CDN_URL="http://cdn.unvanquished.net/$VERSION/pkg/"
@@ -14,7 +14,7 @@
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -24,7 +24,7 @@
* THE SOFTWARE.
*
*/
//#include "precompiled.h"
#include <Rocket/Controls/Controls.h>
#include <Rocket/Core/Core.h>
@@ -53,7 +53,7 @@ void LuaType<T>::Register(lua_State* L)
//hide metatable from Lua getmetatable()
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_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]
@@ -89,7 +89,7 @@ int LuaType<T>::push(lua_State *L, T* obj, bool gc)
int ud = lua_gettop(L); //ud = 2
if(ptrHold != NULL)
{
*ptrHold = obj;
*ptrHold = obj;
lua_pushvalue(L, mt); // ->[3] = copy of [1]
lua_setmetatable(L, -2); //[-2 = 2] -> [2]'s metatable = [3]; pop [3]
char name[32];
@@ -298,7 +298,7 @@ int LuaType<T>::newindex(lua_State* L)
lua_pushvalue(L,1); //userdata at [7]
lua_pushvalue(L,3); //[8] = copy of [3]
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
lua_pop(L,1); //not a setter function.
@@ -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_getfield(L,methods, "__getters"); // -> table[1]
if(lua_isnoneornil(L,-1))
{
View
@@ -30,6 +30,6 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>0.44</string>
<string>0.45</string>
</dict>
</plist>
View
@@ -113,7 +113,7 @@
<br />
<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>
</window>
View
@@ -124,7 +124,7 @@
<br />
<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>
</window>
@@ -395,6 +395,9 @@ void Rocket_Shutdown()
extern std::map<std::string, RocketDataGrid*> dataSourceMap;
extern std::queue< RocketEvent_t* > eventQueue;
// Shut down Lua before we clean up contexts
Rocket::Core::Lua::Interpreter::Shutdown();
if ( menuContext )
{
menuContext->RemoveReference();
@@ -407,7 +410,6 @@ void Rocket_Shutdown()
hudContext = nullptr;
}
Rocket::Core::Lua::Interpreter::Shutdown();
Rocket::Core::Shutdown();
// Prevent memory leaks

0 comments on commit c211fc4

Please sign in to comment.