Add FreeArray
This commit is contained in:
parent
a93c7fba9e
commit
4662314839
|
@ -32,6 +32,7 @@
|
||||||
#include "scripts.h"
|
#include "scripts.h"
|
||||||
#include "selfrun.h"
|
#include "selfrun.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
#include "sfall_arrays.h"
|
||||||
#include "sfall_config.h"
|
#include "sfall_config.h"
|
||||||
#include "svga.h"
|
#include "svga.h"
|
||||||
#include "text_font.h"
|
#include "text_font.h"
|
||||||
|
@ -40,7 +41,6 @@
|
||||||
#include "window_manager_private.h"
|
#include "window_manager_private.h"
|
||||||
#include "word_wrap.h"
|
#include "word_wrap.h"
|
||||||
#include "worldmap.h"
|
#include "worldmap.h"
|
||||||
|
|
||||||
namespace fallout {
|
namespace fallout {
|
||||||
|
|
||||||
#define DEATH_WINDOW_WIDTH 640
|
#define DEATH_WINDOW_WIDTH 640
|
||||||
|
@ -375,6 +375,8 @@ static void mainLoop()
|
||||||
|
|
||||||
renderPresent();
|
renderPresent();
|
||||||
sharedFpsLimiter.throttle();
|
sharedFpsLimiter.throttle();
|
||||||
|
|
||||||
|
DeleteAllTempArrays();
|
||||||
}
|
}
|
||||||
|
|
||||||
scriptsDisable();
|
scriptsDisable();
|
||||||
|
|
|
@ -131,4 +131,17 @@ void SetArray(ArrayId array_id, const SFallScriptValue& key, const SFallScriptVa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FreeArray(ArrayId array_id)
|
||||||
|
{
|
||||||
|
// TODO: remove from saved_arrays
|
||||||
|
arrays.erase(array_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeleteAllTempArrays()
|
||||||
|
{
|
||||||
|
for (auto it = temporaryArrays.begin(); it != temporaryArrays.end(); ++it) {
|
||||||
|
FreeArray(*it);
|
||||||
|
}
|
||||||
|
temporaryArrays.clear();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -20,6 +20,7 @@ ProgramValue GetArrayKey(ArrayId array_id, int index);
|
||||||
int LenArray(ArrayId array_id);
|
int LenArray(ArrayId array_id);
|
||||||
ProgramValue GetArray(ArrayId array_id, const SFallScriptValue& key);
|
ProgramValue GetArray(ArrayId array_id, const SFallScriptValue& key);
|
||||||
void SetArray(ArrayId array_id, const SFallScriptValue& key, const SFallScriptValue& val, bool allowUnset);
|
void SetArray(ArrayId array_id, const SFallScriptValue& key, const SFallScriptValue& val, bool allowUnset);
|
||||||
|
void FreeArray(ArrayId array_id);
|
||||||
|
void DeleteAllTempArrays();
|
||||||
}
|
}
|
||||||
#endif /* SFALL_ARRAYS */
|
#endif /* SFALL_ARRAYS */
|
|
@ -304,9 +304,7 @@ static void opCreateArray(Program* program)
|
||||||
{
|
{
|
||||||
auto flags = programStackPopInteger(program);
|
auto flags = programStackPopInteger(program);
|
||||||
auto len = programStackPopInteger(program);
|
auto len = programStackPopInteger(program);
|
||||||
|
|
||||||
auto array_id = CreateArray(len, flags);
|
auto array_id = CreateArray(len, flags);
|
||||||
|
|
||||||
programStackPushInteger(program, array_id);
|
programStackPushInteger(program, array_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,9 +313,7 @@ static void opTempArray(Program* program)
|
||||||
{
|
{
|
||||||
auto flags = programStackPopInteger(program);
|
auto flags = programStackPopInteger(program);
|
||||||
auto len = programStackPopInteger(program);
|
auto len = programStackPopInteger(program);
|
||||||
|
|
||||||
auto array_id = CreateTempArray(len, flags);
|
auto array_id = CreateTempArray(len, flags);
|
||||||
|
|
||||||
programStackPushInteger(program, array_id);
|
programStackPushInteger(program, array_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,6 +326,13 @@ static void opGetArray(Program* program)
|
||||||
programStackPushValue(program, value);
|
programStackPushValue(program, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// free_array
|
||||||
|
static void opFreeArray(Program* program)
|
||||||
|
{
|
||||||
|
auto arrayId = programStackPopInteger(program);
|
||||||
|
FreeArray(arrayId);
|
||||||
|
}
|
||||||
|
|
||||||
// len_array
|
// len_array
|
||||||
static void opLenArray(Program* program)
|
static void opLenArray(Program* program)
|
||||||
{
|
{
|
||||||
|
@ -346,7 +349,7 @@ static void opPartyMemberList(Program* program)
|
||||||
for (int i = 0; i < LenArray(array_id); i++) {
|
for (int i = 0; i < LenArray(array_id); i++) {
|
||||||
SetArray(array_id, SFallScriptValue { i }, SFallScriptValue { objects[i] }, false);
|
SetArray(array_id, SFallScriptValue { i }, SFallScriptValue { objects[i] }, false);
|
||||||
}
|
}
|
||||||
programStackPushInteger(program, 100);
|
programStackPushInteger(program, array_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// round
|
// round
|
||||||
|
@ -393,6 +396,7 @@ void sfallOpcodesInit()
|
||||||
interpreterRegisterOpcode(0x8221, opGetScreenHeight);
|
interpreterRegisterOpcode(0x8221, opGetScreenHeight);
|
||||||
interpreterRegisterOpcode(0x822D, opCreateArray);
|
interpreterRegisterOpcode(0x822D, opCreateArray);
|
||||||
interpreterRegisterOpcode(0x822F, opGetArray);
|
interpreterRegisterOpcode(0x822F, opGetArray);
|
||||||
|
interpreterRegisterOpcode(0x8230, opFreeArray);
|
||||||
interpreterRegisterOpcode(0x8231, opLenArray);
|
interpreterRegisterOpcode(0x8231, opLenArray);
|
||||||
interpreterRegisterOpcode(0x8233, opTempArray);
|
interpreterRegisterOpcode(0x8233, opTempArray);
|
||||||
interpreterRegisterOpcode(0x8237, opParseInt);
|
interpreterRegisterOpcode(0x8237, opParseInt);
|
||||||
|
|
|
@ -27,6 +27,11 @@ SFallScriptValue::SFallScriptValue(ProgramValue& value)
|
||||||
// TODO: If type is string then copy string
|
// TODO: If type is string then copy string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SFallScriptValue::~SFallScriptValue()
|
||||||
|
{
|
||||||
|
// TODO: If type is string then free it
|
||||||
|
}
|
||||||
|
|
||||||
bool SFallScriptValue::isInt() const
|
bool SFallScriptValue::isInt() const
|
||||||
{
|
{
|
||||||
return opcode == VALUE_TYPE_INT;
|
return opcode == VALUE_TYPE_INT;
|
||||||
|
|
|
@ -16,6 +16,8 @@ public:
|
||||||
bool isFloat() const;
|
bool isFloat() const;
|
||||||
bool isPointer() const;
|
bool isPointer() const;
|
||||||
int asInt() const;
|
int asInt() const;
|
||||||
|
|
||||||
|
~SFallScriptValue();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue