2
0
mirror of https://github.com/rehlds/rehlds.git synced 2024-12-27 23:25:45 +03:00

HLTV-Core: Fixed wrong size of lightstyles

HLTV-Console: Added macros LAUNCHER_FIXES
This commit is contained in:
s1lent 2017-12-09 23:24:18 +07:00
parent aac529d2e4
commit e5d26bc4d2
No known key found for this signature in database
GPG Key ID: 0FE401DC73916B5C
4 changed files with 40 additions and 47 deletions

View File

@ -24,7 +24,7 @@ void setupToolchain(NativeBinarySpec b) {
boolean useGcc = project.hasProperty("useGcc")
def cfg = rootProject.createToolchainConfig(b);
cfg.projectInclude(project, '/..', '/../..', '/src', '/../../common', '/../../engine', '/../../public', '/../../public/rehlds');
cfg.singleDefines 'USE_BREAKPAD_HANDLER', 'HLTV', '_CONSOLE'
cfg.singleDefines 'USE_BREAKPAD_HANDLER', 'HLTV', 'LAUNCHER_FIXES', '_CONSOLE'
if (cfg instanceof MsvcToolchainConfig) {
cfg.compilerOptions.pchConfig = new MsvcToolchainConfig.PrecompiledHeadersConfig(

View File

@ -353,13 +353,6 @@ void World::AddLightStyle(int index, char *style)
m_System->Printf("WARNING! World::SetLightStyle: style too long (%i).\n", length);
}
// FIXME: code mismatch
// Original code:
// Q_strncopy(..., 64);
// ...[63] = '\0';
// Current code:
// Q_strncopy(..., 64);
// ...[64] = '\0';
Q_strlcpy(m_Lightstyles[index], style);
}

View File

@ -251,8 +251,12 @@ protected:
entity_state_t m_Instanced_BaseLines[MAX_INSTANCED_BASELINES];
int m_MaxInstanced_BaseLine;
// TODO: wtf, why 65? here should be 64
#ifdef HOOK_HLTV
char m_Lightstyles[MAX_LIGHTSTYLES][65];
#else
char m_Lightstyles[MAX_LIGHTSTYLES][64];
#endif // HOOK_HLTV
movevars_t m_MoveVars;
BSPModel m_WorldModel;

View File

@ -4,29 +4,30 @@
#pragma pack(push, 1)
struct delta_test_struct_t {
uint8 b_00; //0
uint8 b_01; //1
uint16 s_02; //2
uint32 i_04; //3
float f_08; //4
float w8_0C; //5
uint8 b_10; //6
uint8 b_11; //7
uint16 s_12; //8
uint32 i_14; //9
float f_18; //10
float w8_1C; //11
float wb_20; //12
char s_24[41]; //13
uint8 b_4D; //14
int i_4E; //15
uint8 b_52; //16
char s_53[9]; //17
uint8 b_5C; //18
int i_5D; //19
uint8 b_61; //20
uint8 b_00; // 0
uint8 b_01; // 1
uint16 s_02; // 2
uint32 i_04; // 3
float f_08; // 4
float w8_0C; // 5
uint8 b_10; // 6
uint8 b_11; // 7
uint16 s_12; // 8
uint32 i_14; // 9
float f_18; // 10
float w8_1C; // 11
float wb_20; // 12
char s_24[41]; // 13
uint8 b_4D; // 14
int i_4E; // 15
uint8 b_52; // 16
char s_53[9]; // 17
uint8 b_5C; // 18
int i_5D; // 19
uint8 b_61; // 20
};
#pragma pack(pop)
typedef delta_test_struct_t dts_t;
struct delta_res_t
@ -40,7 +41,7 @@ NOINLINE void _InitDeltaField(delta_description_t* fieldDesc, int expectedOffset
if (expectedOffset != off) {
rehlds_syserror("%s: Expected and real offset mismatch (%d != %d)", expectedOffset, off);
}
fieldDesc->fieldType = type;
strcpy(fieldDesc->fieldName, name);
fieldDesc->fieldOffset = off;
@ -65,7 +66,6 @@ NOINLINE qboolean _DoMarkFields(void* src, void* dst, delta_t* delta, bool useJi
qboolean sendfields;
#ifdef REHLDS_JIT
if (useJit) {
DELTA_ClearFlags(delta);
return DELTAJit_Fields_Clear_Mark_Check((unsigned char*)src, (unsigned char*)dst, delta, NULL);
} else
#endif
@ -86,7 +86,7 @@ NOINLINE void _MarkAndEnsureCorrectResults(const char* action, delta_t* delta, v
char localFieldsStr[512];
strcpy(localFieldsStr, szFields);
//parse fields
// parse fields
int prevEnd = -1;
for (char* pcc = localFieldsStr; *pcc; pcc++) {
if (*pcc == ' ') {
@ -108,7 +108,7 @@ NOINLINE void _MarkAndEnsureCorrectResults(const char* action, delta_t* delta, v
fields[numFields++] = &delta->pdd[fIdx];
}
//build expected mask
// build expected mask
delta_marked_mask_t expectedMask; expectedMask.u64 = 0;
for (int i = 0; i < numFields; i++) {
delta_description_t* f = fields[i];
@ -117,7 +117,7 @@ NOINLINE void _MarkAndEnsureCorrectResults(const char* action, delta_t* delta, v
}
if (!changed) {
//invert mask
// invert mask
uint64 existingFieldsMask = 0xFFFFFFFFFFFFFFFF;
existingFieldsMask = existingFieldsMask >> (64 - delta->fieldCount);
@ -125,7 +125,7 @@ NOINLINE void _MarkAndEnsureCorrectResults(const char* action, delta_t* delta, v
expectedMask.u64 &= existingFieldsMask;
}
//calculate expected bytecount
// calculate expected bytecount
int expectedBytecount = 0;
for (int i = 0; i < ARRAYSIZE(expectedMask.u8); i++) {
if (expectedMask.u8[i]) {
@ -133,10 +133,10 @@ NOINLINE void _MarkAndEnsureCorrectResults(const char* action, delta_t* delta, v
}
}
//do marking
// do marking
qboolean markResult = _DoMarkFields(src, dst, delta, useJit != 0);
//check marking result
// check marking result
if ((markResult != 0) != (expectedMask.u64 != 0)) {
rehlds_syserror("%s: DoMarkFields returned invalid value %d, expected %s", action, markResult, (expectedMask.u64 == 0) ? "0" : "!0");
}
@ -152,18 +152,17 @@ NOINLINE void _MarkAndEnsureCorrectResults(const char* action, delta_t* delta, v
DELTA_SetSendFlagBits(delta, (int*)returnedMask.u32, &returnedBytecount);
}
//check per-field marks
// check per-field marks
if (returnedMask.u64 != expectedMask.u64) {
rehlds_syserror("%s: DoMarkFields returned invalid mask %llX, expected %llX", action, returnedMask.u64, expectedMask.u64);
}
//check bytecount
// check bytecount
if (returnedBytecount != expectedBytecount) {
rehlds_syserror("%s: DoMarkFields returned invalid bytecount %d, expected %d", action, returnedBytecount, expectedBytecount);
}
}
}
NOINLINE void _GetBitmaskAndBytecount(delta_t* delta, int* bits, int* bytecount, int usejit) {
#ifdef REHLDS_JIT
if (usejit) {
@ -248,7 +247,6 @@ void _DeltaSimpleTests(delta_t* delta, delta_simpletest_data_t* tests, int tests
}
}
TEST(MarkFieldsTest_Simple_Primitives, Delta, 1000) {
EngineInitializer engInitGuard;
@ -354,7 +352,7 @@ TEST(TestDelta_Test, Delta, 1000) {
// change float + float + string
testdata[2].f_18 = 2.0;
testdata[2].wb_20 = 2.0;
strcpy(testdata[2].s_24, "TestDelta_Test" );
strcpy(testdata[2].s_24, "TestDelta_Test");
result[2] = delta->pdd[10].significant_bits + delta->pdd[12].significant_bits + strlen(testdata[2].s_24) * 8 + 8 + (13 / 8 * 8 + 8);
@ -368,8 +366,6 @@ TEST(TestDelta_Test, Delta, 1000) {
for (size_t i = 0; i < 4; i++)
{
int tested = DELTA_TestDelta((uint8 *)&from, (uint8 *)&testdata[i], delta);
if (tested != result[i])
rehlds_syserror("TestDelta_Test: returned bitcount %i is not equal to true value %i", tested, result[i]);
CHECK(va("TestDelta_Test: returned bitcount %i is not equal to true value %i on iter %i", tested, result[i], i), tested == result[i]);
}
}