Skip to content

Commit

Permalink
Fixed a bug in multiplayer when changing levels. fix #20
Browse files Browse the repository at this point in the history
  • Loading branch information
tx00100xt committed Oct 21, 2023
1 parent 077622e commit 17d8142
Show file tree
Hide file tree
Showing 4 changed files with 214 additions and 921 deletions.
60 changes: 7 additions & 53 deletions SamTFE/Sources/GameMP/LoadingHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,10 @@ extern CGame *_pGame;
#endif
static CDrawPort *_pdpLoadingHook = NULL; // drawport for loading hook
extern BOOL _bUserBreakEnabled;
extern BOOL map_bIsFirstEncounter;


#define REFRESHTIME (0.2f)

void RemapLevelNames(INDEX &iLevel)
{
switch( iLevel) {
case 10: iLevel = 1; break;
case 11: iLevel = 2; break;
case 12: iLevel = 3; break;
case 13: iLevel = 4; break;
case 14: iLevel = 5; break;
case 15: iLevel = 6; break;
case 21: iLevel = 7; break;
case 22: iLevel = 8; break;
case 23: iLevel = 9; break;
case 24: iLevel = 10; break;
case 31: iLevel = 11; break;
case 32: iLevel = 12; break;
case 33: iLevel = 13; break;
default: iLevel = -1; break;
}
}


static void LoadingHook_t(CProgressHookInfo *pphi)
{
// if user presses escape
Expand Down Expand Up @@ -93,49 +71,25 @@ static void LoadingHook_t(CProgressHookInfo *pphi)
CDrawPort *pdp = _pdpLoadingHook;
ASSERT(pdp!=NULL);
CDrawPort dpHook(pdp, TRUE);
if( !dpHook.Lock()) return;
if(!dpHook.Lock()) {
// do nothing
return;
}

// clear screen
dpHook.Fill(C_BLACK|255);

// get session properties currently loading
CSessionProperties *psp = (CSessionProperties *)_pNetwork->GetSessionProperties();
ULONG ulLevelMask = psp->sp_ulLevelsMask;
INDEX iLevel = -1;
if (psp->sp_bCooperative) {
INDEX iLevel = -1;
INDEX iLevelNext = -1;
CTString strLevelName = _pNetwork->ga_fnmWorld.FileName();
CTString strNextLevelName = _pNetwork->ga_fnmNextLevel.FileName();

// second encounter
INDEX u, v;
u = v = -1;
strLevelName.ScanF("%01d_%01d_", &u, &v);
iLevel = u*10+v;
RemapLevelNames(iLevel);
u = v = -1;
strNextLevelName.ScanF("%01d_%01d_", &u, &v);
iLevelNext = u*10+v;
RemapLevelNames(iLevelNext);

// first encounter
if((iLevel == -1) && (_pNetwork->md_strGameID == "serioussam") ) {
strLevelName.ScanF("%02d_", &iLevel);
strNextLevelName.ScanF("%02d_", &iLevelNext);

/*if(iLevel != -1) {
map_bIsFirstEncounter = TRUE;
}
} else {
map_bIsFirstEncounter = FALSE;*/
}

if(_pNetwork->md_strGameID == "serioussam") {
map_bIsFirstEncounter = TRUE;
} else {
map_bIsFirstEncounter = FALSE;
}

strLevelName.ScanF("%02d_", &iLevel);
strNextLevelName.ScanF("%02d_", &iLevelNext);
if (iLevel>0) {
ulLevelMask|=1<<(iLevel-1);
}
Expand Down
Loading

0 comments on commit 17d8142

Please sign in to comment.