mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-09-02 12:32:40 +02:00
#define MAX_FIGHTERS + some fixes
This commit is contained in:
@@ -1377,7 +1377,7 @@ void Renderer::render_parts()
|
|||||||
cplayer = &sim->player;
|
cplayer = &sim->player;
|
||||||
else if(t==PT_STKM2)
|
else if(t==PT_STKM2)
|
||||||
cplayer = &sim->player2;
|
cplayer = &sim->player2;
|
||||||
else if(t==PT_FIGH)
|
else if (t==PT_FIGH && sim->parts[i].tmp >= 0 && sim->parts[i].tmp < MAX_FIGHTERS)
|
||||||
cplayer = &sim->fighters[(unsigned char)sim->parts[i].tmp];
|
cplayer = &sim->fighters[(unsigned char)sim->parts[i].tmp];
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
|
@@ -148,8 +148,7 @@ int Simulation::Load(int fullX, int fullY, GameSave * save)
|
|||||||
}
|
}
|
||||||
else if (parts[i].type == PT_FIGH)
|
else if (parts[i].type == PT_FIGH)
|
||||||
{
|
{
|
||||||
//TODO: 100 should be replaced with a macro
|
for (int fcount = 0; fcount < MAX_FIGHTERS; fcount++)
|
||||||
for(int fcount = 0; fcount < 100; fcount++)
|
|
||||||
{
|
{
|
||||||
if(!fighters[fcount].spwn)
|
if(!fighters[fcount].spwn)
|
||||||
{
|
{
|
||||||
@@ -318,7 +317,7 @@ Snapshot * Simulation::CreateSnapshot()
|
|||||||
snap->FanVelocityY.insert(snap->FanVelocityY.begin(), &fvy[0][0], &fvy[0][0]+((XRES/CELL)*(YRES/CELL)));
|
snap->FanVelocityY.insert(snap->FanVelocityY.begin(), &fvy[0][0], &fvy[0][0]+((XRES/CELL)*(YRES/CELL)));
|
||||||
snap->stickmen.push_back(player2);
|
snap->stickmen.push_back(player2);
|
||||||
snap->stickmen.push_back(player);
|
snap->stickmen.push_back(player);
|
||||||
snap->stickmen.insert(snap->stickmen.begin(), &fighters[0], &fighters[255]);
|
snap->stickmen.insert(snap->stickmen.begin(), &fighters[0], &fighters[MAX_FIGHTERS]);
|
||||||
snap->signs = signs;
|
snap->signs = signs;
|
||||||
return snap;
|
return snap;
|
||||||
}
|
}
|
||||||
@@ -2686,6 +2685,16 @@ void Simulation::part_change_type(int i, int x, int y, int t)//changes the type
|
|||||||
kill_part(i);
|
kill_part(i);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else if ((t == PT_STKM || t == PT_STKM2 || t == PT_SPAWN || t == PT_SPAWN2) && elementCount[t])
|
||||||
|
{
|
||||||
|
kill_part(i);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if ((t == PT_STKM && player.spwn) || (t == PT_STKM2 && player2.spwn))
|
||||||
|
{
|
||||||
|
kill_part(i);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (parts[i].type == PT_STKM)
|
if (parts[i].type == PT_STKM)
|
||||||
player.spwn = 0;
|
player.spwn = 0;
|
||||||
@@ -2709,17 +2718,6 @@ void Simulation::part_change_type(int i, int x, int y, int t)//changes the type
|
|||||||
else if (parts[i].type == PT_SOAP)
|
else if (parts[i].type == PT_SOAP)
|
||||||
Element_SOAP::detach(this, i);
|
Element_SOAP::detach(this, i);
|
||||||
|
|
||||||
if ((t == PT_STKM || t == PT_STKM2 || t == PT_SPAWN || t == PT_SPAWN2) && elementCount[t])
|
|
||||||
{
|
|
||||||
kill_part(i);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if ((t == PT_STKM && player.spwn) || (t == PT_STKM2 && player2.spwn))
|
|
||||||
{
|
|
||||||
kill_part(i);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parts[i].type > 0 && parts[i].type < PT_NUM && elementCount[parts[i].type])
|
if (parts[i].type > 0 && parts[i].type < PT_NUM && elementCount[parts[i].type])
|
||||||
elementCount[parts[i].type]--;
|
elementCount[parts[i].type]--;
|
||||||
elementCount[t]++;
|
elementCount[t]++;
|
||||||
@@ -2734,8 +2732,8 @@ void Simulation::part_change_type(int i, int x, int y, int t)//changes the type
|
|||||||
Element_STKM::STKM_init_legs(this, &player2, i);
|
Element_STKM::STKM_init_legs(this, &player2, i);
|
||||||
else if (t == PT_FIGH)
|
else if (t == PT_FIGH)
|
||||||
{
|
{
|
||||||
if (parts[i].tmp2 >= 0 && parts[i].tmp2 < 100)
|
if (parts[i].tmp >= 0 && parts[i].tmp < MAX_FIGHTERS)
|
||||||
Element_STKM::STKM_init_legs(this, &fighters[parts[i].tmp2], i);
|
Element_STKM::STKM_init_legs(this, &fighters[parts[i].tmp], i);
|
||||||
}
|
}
|
||||||
|
|
||||||
parts[i].type = t;
|
parts[i].type = t;
|
||||||
@@ -3097,8 +3095,8 @@ int Simulation::create_part(int p, int x, int y, int tv)
|
|||||||
case PT_FIGH:
|
case PT_FIGH:
|
||||||
{
|
{
|
||||||
unsigned char fcount = 0;
|
unsigned char fcount = 0;
|
||||||
while (fcount < 100 && fcount < (fighcount+1) && fighters[fcount].spwn==1) fcount++;
|
while (fcount < MAX_FIGHTERS && fcount < (fighcount+1) && fighters[fcount].spwn==1) fcount++;
|
||||||
if (fcount < 100 && fighters[fcount].spwn==0)
|
if (fcount < MAX_FIGHTERS && fighters[fcount].spwn==0)
|
||||||
{
|
{
|
||||||
parts[i].life = 100;
|
parts[i].life = 100;
|
||||||
parts[i].tmp = fcount;
|
parts[i].tmp = fcount;
|
||||||
@@ -4407,7 +4405,7 @@ killed:
|
|||||||
stickman = &player;
|
stickman = &player;
|
||||||
else if (t == PT_STKM2)
|
else if (t == PT_STKM2)
|
||||||
stickman = &player2;
|
stickman = &player2;
|
||||||
else if (t == PT_FIGH && parts[i].tmp >= 0 && parts[i].tmp < 256)
|
else if (t == PT_FIGH && parts[i].tmp >= 0 && parts[i].tmp < MAX_FIGHTERS)
|
||||||
stickman = &fighters[parts[i].tmp];
|
stickman = &fighters[parts[i].tmp];
|
||||||
|
|
||||||
if (stickman)
|
if (stickman)
|
||||||
|
@@ -64,7 +64,7 @@ public:
|
|||||||
//Stickman
|
//Stickman
|
||||||
playerst player;
|
playerst player;
|
||||||
playerst player2;
|
playerst player2;
|
||||||
playerst fighters[256]; //255 is the maximum number of fighters
|
playerst fighters[MAX_FIGHTERS]; //Defined in Stickman.h
|
||||||
unsigned char fighcount; //Contains the number of fighters
|
unsigned char fighcount; //Contains the number of fighters
|
||||||
bool gravWallChanged;
|
bool gravWallChanged;
|
||||||
//Portals and Wifi
|
//Portals and Wifi
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
#ifndef STICKMAN_H_
|
#ifndef STICKMAN_H_
|
||||||
#define STICKMAN_H_
|
#define STICKMAN_H_
|
||||||
|
|
||||||
|
#define MAX_FIGHTERS 100
|
||||||
struct playerst
|
struct playerst
|
||||||
{
|
{
|
||||||
char comm; //command cell
|
char comm; //command cell
|
||||||
|
@@ -49,6 +49,11 @@ Element_FIGH::Element_FIGH()
|
|||||||
//#TPT-Directive ElementHeader Element_FIGH static int update(UPDATE_FUNC_ARGS)
|
//#TPT-Directive ElementHeader Element_FIGH static int update(UPDATE_FUNC_ARGS)
|
||||||
int Element_FIGH::update(UPDATE_FUNC_ARGS)
|
int Element_FIGH::update(UPDATE_FUNC_ARGS)
|
||||||
{
|
{
|
||||||
|
if (parts[i].tmp < 0 || parts[i].tmp >= MAX_FIGHTERS)
|
||||||
|
{
|
||||||
|
sim->kill_part(i);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
playerst* figh = &sim->fighters[(unsigned char)parts[i].tmp];
|
playerst* figh = &sim->fighters[(unsigned char)parts[i].tmp];
|
||||||
|
|
||||||
unsigned int tarx, tary;
|
unsigned int tarx, tary;
|
||||||
|
Reference in New Issue
Block a user