2
0
mirror of https://github.com/rehlds/rehlds.git synced 2025-01-01 01:25:38 +03:00

Merge pull request #94 from s1lentq/master

Fix: types
This commit is contained in:
theAsmodai 2015-11-08 17:06:04 +03:00
commit f6dad529ee
5 changed files with 58 additions and 52 deletions

View File

@ -193,7 +193,7 @@ typedef struct client_state_s
int max_edicts;
resource_t resourcesonhand;
resource_t resourcesneeded;
resource_t resourcelist[1280];
resource_t resourcelist[MAX_RESOURCE_LIST];
int num_resources;
qboolean need_force_consistency_response;
char serverinfo[512];
@ -236,7 +236,7 @@ typedef struct client_state_s
model_t *model_precache[HL_MODEL_MAX];
int model_precache_count;
sfx_s *sound_precache[HL_SOUND_MAX];
consistency_t consistency_list[512];
consistency_t consistency_list[MAX_CONSISTENCY_LIST];
int num_consistency;
int highentity;
char levelname[40];

View File

@ -90,31 +90,31 @@ qboolean COM_CreateCustomization(customization_t *pListHead, resource_t *pResour
customization_t *pCust; // 91
qboolean bError; // 92
bError = 0;
bError = FALSE;
if (pCustomization)
*pCustomization = 0;
*pCustomization = NULL;
pCust = (customization_t *)Mem_ZeroMalloc(sizeof(customization_t));
Q_memcpy(&pCust->resource, pResource, sizeof(pCust->resource));
if (pResource->nDownloadSize <= 0)
{
bError = 1;
bError = TRUE;
goto CustomizationError;
}
pCust->bInUse = 1;
pCust->bInUse = TRUE;
if (flags & 1)
if (flags & FCUST_FROMHPAK)
{
if (!HPAK_GetDataPointer("custom.hpk", pResource, (uint8**)&pCust->pBuffer, 0))
if (!HPAK_GetDataPointer("custom.hpk", pResource, (uint8**)&pCust->pBuffer, NULL))
{
bError = 1;
bError = TRUE;
goto CustomizationError;
}
}
else
{
pCust->pBuffer = COM_LoadFile(pResource->szFileName, 5, 0);
pCust->pBuffer = COM_LoadFile(pResource->szFileName, 5, NULL);
}
if ((pCust->resource.ucFlags & RES_CUSTOM) && pCust->resource.type == t_decal)
@ -122,13 +122,13 @@ qboolean COM_CreateCustomization(customization_t *pListHead, resource_t *pResour
pCust->resource.playernum = playernumber;
if (!CustomDecal_Validate(pCust->pBuffer, pResource->nDownloadSize))
{
bError = 1;
bError = TRUE;
goto CustomizationError;
}
if (!(flags & 4))
if (!(flags & RES_CUSTOM))
{
cachewad_t * pWad = (cachewad_t *)Mem_ZeroMalloc(0x2Cu);
cachewad_t * pWad = (cachewad_t *)Mem_ZeroMalloc(sizeof(cachewad_t));
pCust->pInfo = pWad;
if (pResource->nDownloadSize >= 1024 && pResource->nDownloadSize <= 20480)
{
@ -141,16 +141,16 @@ qboolean COM_CreateCustomization(customization_t *pListHead, resource_t *pResour
if (nLumps)
*nLumps = pWad->lumpCount;
pCust->bTranslated = 1;
pCust->bTranslated = TRUE;
pCust->nUserData1 = 0;
pCust->nUserData2 = pWad->lumpCount;
if (flags & 2)
if (flags & FCUST_WIPEDATA)
{
Mem_Free(pWad->name);
Mem_Free(pWad->cache);
Mem_Free(pWad->lumps);
Mem_Free(pCust->pInfo);
pCust->pInfo = 0;
pCust->pInfo = NULL;
}
}
}
@ -173,7 +173,7 @@ CustomizationError:
pCust->pNext = pListHead->pNext;
pListHead->pNext = pCust;
}
return bError == 0;
return bError == FALSE;
}
/* <9b41> ../engine/com_custom.c:229 */

View File

@ -40,6 +40,8 @@
#define MAX_NAME 32
#define MAX_LIGHTSTYLES 64
#define MAX_PACKET_ENTITIES 256
#define MAX_RESOURCE_LIST 1280
#define MAX_CONSISTENCY_LIST 512
#ifdef REHLDS_OPT_PEDANTIC
#define MAX_CHALLENGES 64
#else
@ -129,9 +131,9 @@ typedef struct server_s
struct model_s *worldmodel;
CRC32_t worldmapCRC;
unsigned char clientdllmd5[16];
resource_t resourcelist[1280];
resource_t resourcelist[MAX_RESOURCE_LIST];
int num_resources;
consistency_t consistency_list[512];
consistency_t consistency_list[MAX_CONSISTENCY_LIST];
int num_consistency;
const char *model_precache[HL_MODEL_MAX];
struct model_s *models[HL_MODEL_MAX];

View File

@ -1676,7 +1676,7 @@ void SV_Spawn_f(void)
SZ_Write(&msg, g_psv.signon.data, g_psv.signon.cursize);
SV_WriteSpawn(&msg);
SV_WriteVoiceCodec(&msg);
Netchan_CreateFragments(1, &host_client->netchan, &msg);
Netchan_CreateFragments(TRUE, &host_client->netchan, &msg);
Netchan_FragSend(&host_client->netchan);
}
else
@ -2408,7 +2408,7 @@ void EXT_FUNC SV_ConnectClient_internal(void)
SV_ExtractFromUserinfo(host_client);
Info_SetValueForStarKey(host_client->userinfo, "*sid", va("%lld", host_client->network_userid.m_SteamID), MAX_INFO_STRING);
host_client->datagram.flags = 1;
host_client->datagram.flags = SIZEBUF_ALLOW_OVERFLOW;
host_client->datagram.data = (byte *)host_client->datagram_buf;
host_client->datagram.maxsize = sizeof(host_client->datagram_buf);
host_client->datagram.buffername = host_client->name;
@ -2427,7 +2427,7 @@ void SVC_Ping(void)
NET_SendPacket(NS_SERVER, sizeof(data), data, net_from);
}
int SV_GetChallenge(const netadr_t& adr)
int EXT_FUNC SV_GetChallenge(const netadr_t& adr)
{
int i;
#ifndef REHLDS_OPT_PEDANTIC
@ -2787,7 +2787,7 @@ NOXREF void SVC_InfoString(void)
info[0] = 0;
if (*sv_password.string)
if (*sv_password.string)
iHasPW = Q_stricmp(sv_password.string, "none") != 0;
Info_SetValueForKey(info, "protocol", va("%i", PROTOCOL_VERSION), sizeof(info));
@ -3262,7 +3262,7 @@ void SV_AddFailedRcon(netadr_t *adr)
/* <a61f6> ../engine/sv_main.c:4364 */
qboolean SV_CheckRconFailure(netadr_t *adr)
{
for (int i = 0; i < 32; i++)
for (int i = 0; i < MAX_RCON_FAILURES_STORAGE; i++)
{
rcon_failure_t *r = &g_rgRconFailures[i];
if (NET_CompareAdr(*adr, r->adr))
@ -3495,7 +3495,7 @@ void SV_ProcessFile(client_t *cl, char *filename)
pList = pList->pNext;
}
if (!COM_CreateCustomization(&cl->customdata, resource, -1, 7, NULL, NULL))
if (!COM_CreateCustomization(&cl->customdata, resource, -1, (FCUST_FROMHPAK | FCUST_WIPEDATA | RES_CUSTOM), NULL, NULL))
Con_Printf("Error parsing custom decal from %s\n", cl->name);
}
@ -4235,7 +4235,7 @@ int SV_CreatePacketEntities(sv_delta_t type, client_t *client, packet_entities_t
FALSE,
custom,
&numbase,
from == 0,
from == NULL,
0);
entity_state_t *baseline_ = &g_psv.baselines[newindex];
@ -4259,7 +4259,7 @@ int SV_CreatePacketEntities(sv_delta_t type, client_t *client, packet_entities_t
_mm_prefetch((const char*)baseline_, _MM_HINT_T0);
_mm_prefetch(((const char*)baseline_) + 64, _MM_HINT_T0);
if (offset)
SV_SetCallback(newindex, 0, custom, &numbase, 1, offset);
SV_SetCallback(newindex, FALSE, custom, &numbase, TRUE, offset);
// fix for https://github.com/dreamstalker/rehlds/issues/24
#ifdef REHLDS_FIXES
@ -4323,16 +4323,16 @@ qboolean SV_ShouldUpdatePing(client_t *client)
if (client->proxy)
{
if (realtime < client->nextping)
return 0;
return FALSE;
client->nextping = realtime + 2.0;
return 1;
return TRUE;
}
//useless call
//SV_CalcPing(client);
return client->lastcmd.buttons & 0x8000;
return client->lastcmd.buttons & IN_SCORE;
}
/* <a9109> ../engine/sv_main.c:5734 */
@ -4441,7 +4441,6 @@ void SV_EmitPings(client_t *client, sizebuf_t *msg)
/* <a947b> ../engine/sv_main.c:5878 */
void SV_WriteEntitiesToClient(client_t *client, sizebuf_t *msg)
{
client_frame_t *frame = &client->frames[SV_UPDATE_MASK & client->netchan.outgoing_sequence];
unsigned char *pvs = NULL;
@ -4919,7 +4918,7 @@ int SV_ModelIndex(const char *name)
void SV_AddResource(resourcetype_t type, const char *name, int size, unsigned char flags, int index)
{
resource_t *r;
if (g_psv.num_resources >= 1280)
if (g_psv.num_resources >= MAX_RESOURCE_LIST)
Sys_Error("Too many resources on server.");
r = &g_psv.resourcelist[g_psv.num_resources++];
@ -5010,7 +5009,7 @@ void SV_CreateResourceList(void)
else
nSize = 0;
SV_AddResource(t_generic, *s, nSize, 1, i);
SV_AddResource(t_generic, *s, nSize, RES_FATALIFMISSING, i);
}
#ifdef REHLDS_CHECKS
for (i = 1, s = &g_psv.sound_precache[1]; i < HL_SOUND_MAX && *s != NULL; i++, s++)
@ -5023,7 +5022,7 @@ void SV_CreateResourceList(void)
if (!ffirstsent)
{
ffirstsent = 1;
SV_AddResource(t_sound, "!", 0, 1, i);
SV_AddResource(t_sound, "!", 0, RES_FATALIFMISSING, i);
}
}
else
@ -5056,7 +5055,7 @@ void SV_CreateResourceList(void)
if (!ep->filename)
break;
SV_AddResource(t_eventscript, (char *)ep->filename, ep->filesize, 1, i);
SV_AddResource(t_eventscript, (char *)ep->filename, ep->filesize, RES_FATALIFMISSING, i);
}
}
@ -5109,7 +5108,7 @@ void SV_PropagateCustomizations(void)
MSG_WriteByte(&host_client->netchan.message, pResource->ucFlags);
if (pResource->ucFlags & RES_CUSTOM)
{
SZ_Write(&host_client->netchan.message, pResource->rgucMD5_hash, 16);
SZ_Write(&host_client->netchan.message, pResource->rgucMD5_hash, sizeof(pResource->rgucMD5_hash));
}
}
@ -5181,10 +5180,12 @@ void SV_CreateBaseline(void)
{
player = SV_IsPlayerIndex(entnum);
g_psv.baselines[entnum].number = entnum;
g_psv.baselines[entnum].entityType = 1;
// set entity type
if (svent->v.flags & FL_CUSTOMENTITY)
g_psv.baselines[entnum].entityType = 2;
g_psv.baselines[entnum].entityType = ENTITY_BEAM;
else
g_psv.baselines[entnum].entityType = ENTITY_NORMAL;
__invokeValvesBuggedCreateBaseline((void *)gEntityInterface.pfnCreateBaseline, player, entnum, &(g_psv.baselines[entnum]), svent, sv_playermodel, player_mins[0], player_maxs[0]);
sv_lastnum = entnum;
@ -5201,7 +5202,7 @@ void SV_CreateBaseline(void)
{
MSG_WriteBits(entnum, 11);
MSG_WriteBits(g_psv.baselines[entnum].entityType, 2);
custom = ~g_psv.baselines[entnum].entityType & 1;
custom = ~g_psv.baselines[entnum].entityType & ENTITY_NORMAL;
if (custom)
pDelta = g_pcustomentitydelta;
else
@ -5790,12 +5791,12 @@ USERID_t *SV_StringToUserID(const char *str)
if (Q_strnicmp(str, "STEAM_", 6))
{
Q_strncpy(szTemp, pszUserID, sizeof(szTemp) - 1);
id.idtype = 2;
id.idtype = AUTH_IDTYPE_VALVE;
}
else
{
Q_strncpy(szTemp, pszUserID, sizeof(szTemp) - 1);
id.idtype = 1;
id.idtype = AUTH_IDTYPE_STEAM;
}
szTemp[127] = 0;
id.m_SteamID = Steam_StringToSteamID(szTemp);
@ -6126,7 +6127,7 @@ void Host_Kick_f(void)
SV_ClientPrintf("Kicked by %s\n", who);
Log_Printf("Kick: \"%s<%i><%s><>\" was kicked by \"%s\"\n", host_client->name, host_client->userid, SV_GetClientIDString(host_client), who);
SV_DropClient(host_client, 0, "Kicked");
SV_DropClient(host_client, FALSE, "Kicked");
}
host_client = save;
}
@ -6143,7 +6144,8 @@ void SV_RemoveId_f(void)
}
Q_strncpy(idstring, Cmd_Argv(1), sizeof(idstring) - 1);
idstring[63] = 0;
idstring[sizeof(idstring) - 1] = 0;
if (!idstring[0])
{
Con_Printf(__FUNCTION__ ": Id string is empty!\n");
@ -6173,8 +6175,10 @@ void SV_RemoveId_f(void)
{
if (!Q_strnicmp(idstring, "STEAM_", 6) || !Q_strnicmp(idstring, "VALVE_", 6))
{
Q_snprintf(idstring, 0x3Fu, "%s:%s:%s", Cmd_Argv(1), Cmd_Argv(3), Cmd_Argv(5));
Q_snprintf(idstring, sizeof(idstring) - 1, "%s:%s:%s", Cmd_Argv(1), Cmd_Argv(3), Cmd_Argv(5));
#ifndef REHLDS_FIXES
idstring[63] = 0;
#endif // REHLDS_FIXES
}
for (int i = 0; i < numuserfilters; i++)
@ -6605,7 +6609,7 @@ void SV_BeginFileDownload_f(void)
#ifdef REHLDS_FIXES
if (pbuf && size)
{
Netchan_CreateFileFragmentsFromBuffer(1, &host_client->netchan, name, pbuf, size);
Netchan_CreateFileFragmentsFromBuffer(TRUE, &host_client->netchan, name, pbuf, size);
Netchan_FragSend(&host_client->netchan);
}
// Mem_Free pbuf even if size is zero
@ -6616,7 +6620,7 @@ void SV_BeginFileDownload_f(void)
#else // REHLDS_FIXES
if (pbuf && size)
{
Netchan_CreateFileFragmentsFromBuffer(1, &host_client->netchan, name, pbuf, size);
Netchan_CreateFileFragmentsFromBuffer(TRUE, &host_client->netchan, name, pbuf, size);
Netchan_FragSend(&host_client->netchan);
Mem_Free((void *)pbuf);
}

View File

@ -211,7 +211,7 @@ void SV_ParseConsistencyResponse(client_t *pSenderClient)
{
msg_badread = 1;
Con_Printf("SV_ParseConsistencyResponse: %s:%s sent bad file data\n", host_client->name, NET_AdrToString(host_client->netchan.remote_address));
SV_DropClient(host_client, 0, "Bad file data");
SV_DropClient(host_client, FALSE, "Bad file data");
return;
}
@ -226,7 +226,7 @@ void SV_ParseConsistencyResponse(client_t *pSenderClient)
if (dropmessage[0])
SV_ClientPrintf("%s", dropmessage);
SV_DropClient(host_client, 0, "Bad file %s", g_psv.resourcelist[c - 1].szFileName); // only filename. reason was printed in console if exists.
SV_DropClient(host_client, FALSE, "Bad file %s", g_psv.resourcelist[c - 1].szFileName); // only filename. reason was printed in console if exists.
}
#else // REHLDS_FIXES
if (gEntityInterface.pfnInconsistentFile(host_client->edict, g_psv.resourcelist[c - 1].szFileName, dropmessage))
@ -234,7 +234,7 @@ void SV_ParseConsistencyResponse(client_t *pSenderClient)
if (Q_strlen(dropmessage) > 0)
SV_ClientPrintf("%s", dropmessage);
SV_DropClient(host_client, 0, "Bad file %s", dropmessage);
SV_DropClient(host_client, FALSE, "Bad file %s", dropmessage);
}
#endif // REHLDS_FIXES
@ -1515,7 +1515,7 @@ void SV_ParseMove(client_t *pSenderClient)
if (totalcmds < 0 || totalcmds >= 63)
{
Con_Printf("SV_ReadClientMessage: too many cmds %i sent for %s/%s\n", totalcmds, host_client->name, NET_AdrToString(host_client->netchan.remote_address));
SV_DropClient(host_client, 0, "CMD_MAXBACKUP hit");
SV_DropClient(host_client, FALSE, "CMD_MAXBACKUP hit");
msg_badread = 1;
return;
}
@ -1630,7 +1630,7 @@ void SV_ParseVoiceData(client_t *cl)
if (nDataLength > sizeof(chReceived))
{
Con_DPrintf("SV_ParseVoiceData: invalid incoming packet.\n");
SV_DropClient(cl, 0, "Invalid voice data\n");
SV_DropClient(cl, FALSE, "Invalid voice data\n");
return;
}
@ -1701,7 +1701,7 @@ void EXT_FUNC SV_HandleClientMessage_api(IGameClient* client, int8 opcode) {
if (opcode < clc_bad || opcode > clc_cvarvalue2)
{
Con_Printf("SV_ReadClientMessage: unknown command char (%d)\n", opcode);
SV_DropClient(cl, 0, "Bad command character in client command");
SV_DropClient(cl, FALSE, "Bad command character in client command");
return;
}