Fixed compilation issues with g++

This commit is contained in:
L 2023-02-06 19:24:01 +01:00
parent d4e366ee14
commit 6eb1ec3cf5
6 changed files with 74 additions and 67 deletions

View file

@ -55,7 +55,7 @@ These are the tools required for all platforms :
- Flex and Bison
- Clang (at least version 11)
At least C++17 is required. Avoid GCC/G++ because it uses nonstandard extensions.
At least a C++17 compiler is required, clang is preferred over GCC.
The installation directory can be set to MOHAA directory.

View file

@ -14523,7 +14523,8 @@ void Actor::ResolveVoiceType
return;
}
}
sprintf(validVoice, "");
validVoice[0] = '\0';
for (int i = 0; i < 3; i++)
{
strcat(validVoice, gAmericanVoices[i]);
@ -14545,7 +14546,8 @@ void Actor::ResolveVoiceType
return;
}
}
sprintf(validVoice, "");
validVoice[0] = '\0';
for (int i = 0; i < 3; i++)
{
strcat(validVoice, gGermanVoices[i]);

View file

@ -80,7 +80,7 @@ void con_arrayset<key, value>::resize( int count )
if( oldTableLength > 1 )
{
oldReverseTable++;
++oldReverseTable;
delete[] oldReverseTable;
}
}

View file

@ -41,6 +41,26 @@ enum class alloc_source_e { SourceBlock = 174, SourceMalloc };
template<typename aclass, size_t blocksize>
class MEM_BlockAlloc_enum;
template<size_t bits>
struct block_selectType_t;
template<>
struct block_selectType_t<8> {
using type = uint8_t;
};
template<>
struct block_selectType_t<16> {
using type = uint16_t;
};
template<>
struct block_selectType_t<32> {
using type = uint32_t;
};
template<>
struct block_selectType_t<64> {
using type = uint64_t;
};
template<typename aclass, size_t blocksize>
class block_s
{
@ -59,27 +79,7 @@ public:
#endif
public:
template<size_t bits>
struct selectType_t;
template<>
struct selectType_t<8> {
using type = uint8_t;
};
template<>
struct selectType_t<16> {
using type = uint16_t;
};
template<>
struct selectType_t<32> {
using type = uint32_t;
};
template<>
struct selectType_t<64> {
using type = uint64_t;
};
using offset_t = typename selectType_t<bitsNeeded>::type;
using offset_t = typename block_selectType_t<bitsNeeded>::type;
struct info_t {
offset_t index;

View file

@ -377,7 +377,8 @@ ScriptConstArrayHolder::~ScriptConstArrayHolder()
{
if (constArrayValue)
{
delete[](constArrayValue + 1);
ScriptVariable* const offset = constArrayValue + 1;
delete[] offset;
}
}
@ -712,7 +713,7 @@ void ScriptVariable::PrintValue( void )
switch (GetType())
{
case VARIABLE_NONE:
printf( "" );
printf("None");
break;
#ifndef NO_SCRIPTENGINE

View file

@ -70,46 +70,9 @@ static const char *typenames[] =
"double"
};
class ScriptArrayHolder {
public:
con_map< ScriptVariable, ScriptVariable > arrayValue;
unsigned int refCount;
public:
void Archive( Archiver& arc );
static void Archive( Archiver& arc, ScriptArrayHolder *& arrayValue );
};
class ScriptConstArrayHolder {
public:
ScriptVariable *constArrayValue;
unsigned int refCount;
unsigned int size;
public:
void Archive( Archiver& arc );
static void Archive( Archiver& arc, ScriptConstArrayHolder *& constArrayValue );
ScriptConstArrayHolder( ScriptVariable *pVar, unsigned int size );
ScriptConstArrayHolder( unsigned int size );
ScriptConstArrayHolder();
~ScriptConstArrayHolder();
};
class ScriptPointer {
public:
Container< ScriptVariable * > list;
public:
void Archive( Archiver& arc );
static void Archive( Archiver& arc, ScriptPointer *& pointerValue );
void Clear();
void add( ScriptVariable *var );
void remove( ScriptVariable *var );
void setValue( const ScriptVariable& var );
};
class ScriptArrayHolder;
class ScriptConstArrayHolder;
class ScriptPointer;
class ScriptVariable {
public:
@ -272,6 +235,47 @@ public:
ScriptVariable operator--( int );
};
class ScriptArrayHolder {
public:
con_map< ScriptVariable, ScriptVariable > arrayValue;
unsigned int refCount;
public:
void Archive( Archiver& arc );
static void Archive( Archiver& arc, ScriptArrayHolder *& arrayValue );
};
class ScriptConstArrayHolder {
public:
ScriptVariable *constArrayValue;
unsigned int refCount;
unsigned int size;
public:
void Archive( Archiver& arc );
static void Archive( Archiver& arc, ScriptConstArrayHolder *& constArrayValue );
ScriptConstArrayHolder( ScriptVariable *pVar, unsigned int size );
ScriptConstArrayHolder( unsigned int size );
ScriptConstArrayHolder();
~ScriptConstArrayHolder();
};
class ScriptPointer {
public:
Container< ScriptVariable * > list;
public:
void Archive( Archiver& arc );
static void Archive( Archiver& arc, ScriptPointer *& pointerValue );
void Clear();
void add( ScriptVariable *var );
void remove( ScriptVariable *var );
void setValue( const ScriptVariable& var );
};
#ifndef NO_SCRIPTENGINE
class ScriptVariableList : public Class