diff --git a/src/elements/prti.cpp b/src/elements/prti.cpp index f5b237490..384fd7e9f 100644 --- a/src/elements/prti.cpp +++ b/src/elements/prti.cpp @@ -29,6 +29,9 @@ int update_PRTI(UPDATE_FUNC_ARGS) { continue; } + if ((r&0xFF)==PT_STKM || (r&0xFF)==PT_STKM2 || (r&0xFF)==PT_FIGH) + continue;// Handling these is a bit more complicated, and is done in STKM_interact() + if ((r&0xFF) == PT_SOAP) sim->detach(r>>8); diff --git a/src/elements/prto.cpp b/src/elements/prto.cpp index 32e72514a..bbef6bed6 100644 --- a/src/elements/prto.cpp +++ b/src/elements/prto.cpp @@ -47,8 +47,31 @@ int update_PRTO(UPDATE_FUNC_ARGS) { sim->player.spwn = 0; if (sim->portalp[parts[i].tmp][randomness][nnx].type==PT_STKM2) sim->player2.spwn = 0; + if (sim->portalp[parts[i].tmp][randomness][nnx].type==PT_FIGH) + { + sim->fighcount--; + sim->fighters[(unsigned char)sim->portalp[parts[i].tmp][randomness][nnx].tmp].spwn = 0; + } np = sim->create_part(-1, x+rx, y+ry, sim->portalp[parts[i].tmp][randomness][nnx].type); - if (np<0) continue; + if (np<0) + { + if (sim->portalp[parts[i].tmp][randomness][nnx].type==PT_STKM) + sim->player.spwn = 1; + if (sim->portalp[parts[i].tmp][randomness][nnx].type==PT_STKM2) + sim->player2.spwn = 1; + if (sim->portalp[parts[i].tmp][randomness][nnx].type==PT_FIGH) + { + sim->fighcount++; + sim->fighters[(unsigned char)sim->portalp[parts[i].tmp][randomness][nnx].tmp].spwn = 1; + } + continue; + } + if (parts[np].type==PT_FIGH) + { + // Release the fighters[] element allocated by create_part, the one reserved when the fighter went into the portal will be used + sim->fighters[(unsigned char)parts[np].tmp].spwn = 0; + sim->fighters[(unsigned char)sim->portalp[parts[i].tmp][randomness][nnx].tmp].spwn = 1; + } parts[np] = sim->portalp[parts[i].tmp][randomness][nnx]; parts[np].x = x+rx; parts[np].y = y+ry; diff --git a/src/elements/stkm.cpp b/src/elements/stkm.cpp index 68ef1ed9a..e7eecf401 100644 --- a/src/elements/stkm.cpp +++ b/src/elements/stkm.cpp @@ -453,7 +453,10 @@ void STKM_interact(Simulation * sim, playerst* playerp, int i, int x, int y) { sim->portalp[sim->parts[r>>8].tmp][count][nnx] = sim->parts[i]; sim->kill_part(i); - playerp->spwn = 1;//stop SPWN creating a new STKM while he is in portal + //stop new STKM/fighters being created to replace the ones in the portal: + playerp->spwn = 1; + if (sim->portalp[sim->parts[r>>8].tmp][count][nnx].type==PT_FIGH) + sim->fighcount++; break; } }