Permalink
Browse files

Various cleanups to cl_cgame.cpp

  • Loading branch information...
Kangz committed Oct 29, 2015
1 parent 0bfadc1 commit 87202513e10541b8bcdbf0b6406c7876f9deabd0
@@ -542,7 +542,7 @@ namespace Key {
> GetKeynumForBindsMsg;
// KeyNumToStringMsg
typedef IPC::SyncMessage<
IPC::Message<IPC::Id<VM::QVM, CG_KEY_KEYNUMTOSTRINGBUF>, int, int>,
IPC::Message<IPC::Id<VM::QVM, CG_KEY_KEYNUMTOSTRINGBUF>, int>,
IPC::Reply<std::string>
> KeyNumToStringMsg;
// SetBindingMsg
@@ -89,29 +89,6 @@ int CL_GetCurrentCmdNumber()
return cl.cmdNumber;
}

/*
====================
CL_GetCurrentSnapshotNumber
====================
*/
void CL_GetCurrentSnapshotNumber( int *snapshotNumber, int *serverTime )
{
*snapshotNumber = cl.snap.messageNum;
*serverTime = cl.snap.serverTime;
}

/*
==============
CL_SetUserCmdValue
==============
*/
void CL_SetUserCmdValue( int userCmdValue, int flags, float sensitivityScale )
{
cl.cgameUserCmdValue = userCmdValue;
cl.cgameFlags = flags;
cl.cgameSensitivity = sensitivityScale;
}

/*
=====================
CL_ConfigstringModified
@@ -664,36 +641,6 @@ static int LAN_ServerIsVisible( int source, int n )
return false;
}

/*
* =======================
* LAN_UpdateVisiblePings
* =======================
*/
bool LAN_UpdateVisiblePings( int source )
{
return CL_UpdateVisiblePings_f( source );
}

/*
* ====================
* LAN_GetServerStatus
* ====================
*/
int LAN_GetServerStatus( const char *serverAddress, char *serverStatus, int maxLen )
{
return CL_ServerStatus( serverAddress, serverStatus, maxLen );
}

/*
* ====================
* Key_KeynumToStringBuf
* ====================
*/
void Key_KeynumToStringBuf( int keynum, char *buf, int buflen )
{
Q_strncpyz( buf, Key_KeynumToString( keynum ), buflen );
}

/*
* ====================
* Key_GetBindingBuf
@@ -1303,7 +1250,8 @@ void CGameVM::QVMSyscall(int index, Util::Reader& reader, IPC::Channel& channel)

case CG_GETCURRENTSNAPSHOTNUMBER:
IPC::HandleMsg<GetCurrentSnapshotNumberMsg>(channel, std::move(reader), [this] (int& number, int& serverTime) {
CL_GetCurrentSnapshotNumber(&number, &serverTime);
number = cl.snap.messageNum;
serverTime = cl.snap.serverTime;
});
break;

@@ -1327,7 +1275,9 @@ void CGameVM::QVMSyscall(int index, Util::Reader& reader, IPC::Channel& channel)

case CG_SETUSERCMDVALUE:
IPC::HandleMsg<SetUserCmdValueMsg>(channel, std::move(reader), [this] (int stateValue, int flags, float scale) {
CL_SetUserCmdValue(stateValue, flags, scale);
cl.cgameUserCmdValue = stateValue;
cl.cgameFlags = flags;
cl.cgameSensitivity = scale;
});
break;

@@ -1585,10 +1535,8 @@ void CGameVM::QVMSyscall(int index, Util::Reader& reader, IPC::Channel& channel)
break;

case CG_KEY_KEYNUMTOSTRINGBUF:
IPC::HandleMsg<Key::KeyNumToStringMsg>(channel, std::move(reader), [this] (int keynum, int len, std::string& result) {
std::unique_ptr<char[]> buffer(new char[len]);
Key_KeynumToStringBuf(keynum, buffer.get(), len);
result.assign(buffer.get(), len);
IPC::HandleMsg<Key::KeyNumToStringMsg>(channel, std::move(reader), [this] (int keynum, std::string& result) {
result = Key_KeynumToString(keynum);
});
break;

@@ -1669,7 +1617,7 @@ void CGameVM::QVMSyscall(int index, Util::Reader& reader, IPC::Channel& channel)

case CG_LAN_UPDATEVISIBLEPINGS:
IPC::HandleMsg<LAN::UpdateVisiblePingsMsg>(channel, std::move(reader), [this] (int source, bool& res) {
res = LAN_UpdateVisiblePings(source);
res = CL_UpdateVisiblePings_f(source);
});
break;

@@ -1682,14 +1630,14 @@ void CGameVM::QVMSyscall(int index, Util::Reader& reader, IPC::Channel& channel)
case CG_LAN_SERVERSTATUS:
IPC::HandleMsg<LAN::ServerStatusMsg>(channel, std::move(reader), [this] (const std::string& serverAddress, int len, std::string& status, int& res) {
std::unique_ptr<char[]> buffer(new char[len]);
res = LAN_GetServerStatus(serverAddress.c_str(), buffer.get(), len);
res = CL_ServerStatus(serverAddress.c_str(), buffer.get(), len);
status.assign(buffer.get(), len);
});
break;

case CG_LAN_RESETSERVERSTATUS:
IPC::HandleMsg<LAN::ResetServerStatusMsg>(channel, std::move(reader), [this] {
LAN_GetServerStatus(nullptr, nullptr, 0);
CL_ServerStatus(nullptr, nullptr, 0);
});
break;

@@ -313,13 +313,9 @@ void CL_KeyMove( usercmd_t *cmd )
forward += movespeed * CL_KeyState( &kb[ KB_FORWARD ] );
forward -= movespeed * CL_KeyState( &kb[ KB_BACK ] );

// fretn - moved this to bg_pmove.c
//if (!(cl.snap.ps.persistant[PERS_HWEAPON_USE]))
//{
cmd->forwardmove = ClampChar( forward );
cmd->rightmove = ClampChar( side );
cmd->upmove = ClampChar( up );
//}

// Arnout: double tap
cmd->doubleTap = DT_NONE; // reset
@@ -596,16 +592,6 @@ void CL_MouseMove( usercmd_t *cmd )
mx = cl_sensitivity->value * ( mx + ( ( mx < 0 ) ? -power[ 0 ] : power[ 0 ] ) * cl_mouseAccelOffset->value );
my = cl_sensitivity->value * ( my + ( ( my < 0 ) ? -power[ 1 ] : power[ 1 ] ) * cl_mouseAccelOffset->value );

/* NERVE - SMF - this has moved to CG_CalcFov to fix zoomed-in/out transition movement bug
if ( cl.snap.ps.stats[STAT_ZOOMED_VIEW] ) {
if(cl.snap.ps.weapon == WP_SNIPERRIFLE) {
accelSensitivity *= 0.1;
}
else if(cl.snap.ps.weapon == WP_SNOOPERSCOPE) {
accelSensitivity *= 0.2;
}
}
*/
if ( cl_showMouseRate->integer )
{
Com_Printf( "ratex: %f, ratey: %f, powx: %f, powy: %f", rate[ 0 ], rate[ 1 ], power[ 0 ], power[ 1 ] );
@@ -118,27 +118,14 @@ void CL_ParsePacketEntities( msg_t *msg, const clSnapshot_t *oldframe, clSnapsho
// delta from the entities present in oldframe
oldindex = 0;
oldstate = nullptr;
oldnum = MAX_GENTITIES;

if ( !oldframe )
{
static clSnapshot_t nullframe{};
nullframe.valid = false;

oldframe = &nullframe;
oldnum = MAX_GENTITIES; // guaranteed out of range
}
else
{
if ( oldindex >= oldframe->numEntities )
{
oldnum = MAX_GENTITIES;
}
else
{
oldstate = &cl.parseEntities[
( oldframe->parseEntitiesNum + oldindex ) & ( MAX_PARSE_ENTITIES - 1 ) ];
oldnum = oldstate->number;
}
}

while ( 1 )
@@ -110,11 +110,7 @@ typedef struct
// entities, so that when a delta compressed message arives from the server
// it can be un-deltad from the original

#ifdef USE_INCREASED_ENTITIES
#define MAX_PARSE_ENTITIES ( MAX_GENTITIES * 2 )
#else
#define MAX_PARSE_ENTITIES 2048
#endif

extern int g_console_field_width;

@@ -913,7 +913,6 @@ typedef struct
int used;
} netField_t;

// using the stringizing operator to save typing...
#define NETF( x ) # x,int((size_t)&( (entityState_t*)0 )->x)

static netField_t entityStateFields[] =
@@ -699,7 +699,7 @@ std::vector<std::vector<int>> trap_Key_GetKeynumForBinds(int team, std::vector<s
void trap_Key_KeynumToStringBuf( int keynum, char *buf, int buflen )
{
std::string result;
VM::SendMsg<Key::KeyNumToStringMsg>(keynum, buflen, result);
VM::SendMsg<Key::KeyNumToStringMsg>(keynum, result);
Q_strncpyz(buf, result.c_str(), buflen);
}

0 comments on commit 8720251

Please sign in to comment.