mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-03-20 22:29:48 +01:00
prevent compiling if pmap doesn't have enough space, make lua elements favor 1 byte IDs
This commit is contained in:
parent
b5159ab74e
commit
07988147b9
@ -2526,9 +2526,10 @@ int LuaScriptInterface::elements_allocate(lua_State * l)
|
||||
}
|
||||
|
||||
int newID = -1;
|
||||
for(int i = PT_NUM-1; i >= 0; i--)
|
||||
// Start out at 255 so that lua element IDs are still one byte (better save compatibility)
|
||||
for (int i = PT_NUM >= 255 ? 255 : PT_NUM; i >= 0; i--)
|
||||
{
|
||||
if(!luacon_sim->elements[i].Enabled)
|
||||
if (!luacon_sim->elements[i].Enabled)
|
||||
{
|
||||
newID = i;
|
||||
luacon_sim->elements[i] = Element();
|
||||
@ -2537,8 +2538,23 @@ int LuaScriptInterface::elements_allocate(lua_State * l)
|
||||
break;
|
||||
}
|
||||
}
|
||||
// If not enough space, then we start with the new maimum ID
|
||||
if (newID == -1)
|
||||
{
|
||||
for (int i = PT_NUM-1; i >= 255; i--)
|
||||
{
|
||||
if (!luacon_sim->elements[i].Enabled)
|
||||
{
|
||||
newID = i;
|
||||
luacon_sim->elements[i] = Element();
|
||||
luacon_sim->elements[i].Enabled = true;
|
||||
luacon_sim->elements[i].Identifier = strdup(identifier.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(newID != -1)
|
||||
if (newID != -1)
|
||||
{
|
||||
lua_getglobal(l, "elements");
|
||||
lua_pushinteger(l, newID);
|
||||
|
@ -60,6 +60,13 @@
|
||||
|
||||
#define PT_NUM (1<<PMAPBITS)
|
||||
|
||||
#if PMAPBITS > 16
|
||||
#error PMAPBITS is too large
|
||||
#endif
|
||||
#if ((XRES*YRES)<<PMAPBITS) > 0x100000000L
|
||||
#error not enough space in pmap
|
||||
#endif
|
||||
|
||||
struct playerst;
|
||||
|
||||
#include "ElementClasses.h"
|
||||
|
@ -196,23 +196,6 @@ int Simulation::Load(int fullX, int fullY, GameSave * save, bool includePressure
|
||||
soapList.insert(std::pair<unsigned int, unsigned int>(n, i));
|
||||
break;
|
||||
}
|
||||
|
||||
/*if (save->pmapbits != PMAPBITS)
|
||||
{
|
||||
unsigned int pmapmask = (1<<save->pmapbits)-1;
|
||||
if (parts[i].type == PT_CRAY || parts[i].type == PT_DRAY || parts[i].type == PT_CONV)
|
||||
{
|
||||
int type = parts[i].ctype & pmapmask;
|
||||
int data = parts[i].ctype >> save->pmapbits;
|
||||
parts[i].ctype = PMAP(data, type);
|
||||
}
|
||||
else if (parts[i].type == PT_PIPE || parts[i].type == PT_PPIP)
|
||||
{
|
||||
int type = parts[i].tmp & pmapmask;
|
||||
int data = parts[i].tmp >> save->pmapbits;
|
||||
parts[i].tmp = PMAP(data, type);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
parts_lastActiveIndex = NPART-1;
|
||||
force_stacking_check = true;
|
||||
@ -288,7 +271,7 @@ bool Simulation::TypeInCtype(int el)
|
||||
el == PT_STOR || el == PT_CONV || el == PT_STKM || el == PT_STKM2 ||
|
||||
el == PT_FIGH || el == PT_LAVA || el == PT_SPRK || el == PT_PSTN ||
|
||||
el == PT_CRAY || el == PT_DTEC || el == PT_DRAY || el == PT_PIPE ||
|
||||
el == PT_PPIP;
|
||||
el == PT_PPIP;
|
||||
}
|
||||
|
||||
bool Simulation::TypeInTmp(int el)
|
||||
|
@ -56,7 +56,7 @@ Element_PIPE::Element_PIPE()
|
||||
// 0x00001C00 forward single pixel pipe direction
|
||||
// 0x00002000 will transfer like a single pixel pipe when in reverse mode
|
||||
// 0x0001C000 reverse single pixel pipe direction
|
||||
// 0x00060000 PIPE color data stored here
|
||||
// 0x000E0000 PIPE color data stored here
|
||||
|
||||
#define PFLAG_NORMALSPEED 0x00010000
|
||||
#define PFLAG_INITIALIZING 0x00020000 // colors haven't been set yet
|
||||
|
Loading…
x
Reference in New Issue
Block a user