From d7a235bc8c352c3e4f287617854102fb7a547702 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sat, 17 Nov 2018 19:26:35 +0100 Subject: [PATCH] fixed some shmup-related crashes --- shmup.cpp | 6 +++++- system.cpp | 16 ++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/shmup.cpp b/shmup.cpp index 3c55d780..f08b6ec6 100644 --- a/shmup.cpp +++ b/shmup.cpp @@ -1197,7 +1197,8 @@ void shootBullet(monster *m) { } void killThePlayer(eMonster m) { - pc[cpid]->dead = true; + if(cpid >= 0 && cpid < MAXPLAYER && pc[cpid]) + pc[cpid]->dead = true; } monster *playerCrash(monster *who, hyperpoint where) { @@ -3293,13 +3294,16 @@ void clearMemory() { nextmove = 0; nextdragon = 0; visibleAt = 0; + for(int i=0; ibase; } bool playerInBoat(int i) { + if(!pc[i]) return false; return pc[i]->inBoat; } diff --git a/system.cpp b/system.cpp index 17aa1e7d..220db895 100644 --- a/system.cpp +++ b/system.cpp @@ -97,6 +97,12 @@ void initgame() { DEBB(DF_INIT, (debugfile,"initGame\n")); callhooks(hooks_initgame); + if(!safety) multi::players = vid.scfg.players; + if(multi::players < 1 || multi::players > MAXPLAYER) + multi::players = 1; + multi::whereto[0].d = MD_UNDECIDED; + multi::cpid = 0; + yendor::init(1); if(safety && safetyseed) { @@ -160,6 +166,8 @@ void initgame() { yendor::lastchallenge = yendor::challenge; + if(shmup::on) shmup::init(); + yendor::init(2); clear_euland(specialland); @@ -180,14 +188,6 @@ void initgame() { for(int i=0; i MAXPLAYER) - multi::players = 1; - multi::whereto[0].d = MD_UNDECIDED; - multi::cpid = 0; - - if(shmup::on) shmup::init(); - #if CAP_DAILY daily::split(); #endif