News:

One Minute Game Review by The Happy Friar: https://ugetube.com/@OneMinteGameReviews
Also on Rumble: https://rumble.com/c/c-1115371

idTech 4 (aka Doom 3 tech) Discord Server! https://discord.gg/9wtCGHa

Main Menu

"map" is working but "startgame" craches

Started by bitterman, June 20, 2015, 10:49:59 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

bitterman

When I try to load the map using the "map game/test.map" - map load properly.
When I try to load this map with the command "startgame game/test" from the gui menu - the program crashes.

mapDef "game/test" is declared.

The last console output is PrintWarnings() (see below).

But I don't see any critical sections below.

"gameError" from loaded map is also crashes.

How can I find what causes crashes?

/*
1506 ===============
1507 idSessionLocal::ExecuteMapChange
1508
1509 Performs the initialization of a game based on mapSpawnData, used for both single
1510 player and multiplayer, but not for renderDemos, which don't
1511 create a game at all.
1512 Exits with mapSpawned = true
1513 ===============
1514 */
1515 void idSessionLocal::ExecuteMapChange( bool noFadeWipe ) {
1516  int i;
1517  bool reloadingSameMap;
1518
1519  // close console and remove any prints from the notify lines
1520  console->Close();
1521
1522  if ( IsMultiplayer() ) {
1523  // make sure the mp GUI isn't up, or when players get back in the
1524  // map, mpGame's menu and the gui will be out of sync.
1525  SetGUI( NULL, NULL );
1526  }
1527
1528  // mute sound
1529  soundSystem->SetMute( true );
1530
1531  // clear all menu sounds
1532  menuSoundWorld->ClearAllSoundEmitters();
1533
1534  // unpause the game sound world
1535  // NOTE: we UnPause again later down. not sure this is needed
1536  if ( sw->IsPaused() ) {
1537  sw->UnPause();
1538  }
1539
1540  if ( !noFadeWipe ) {
1541  // capture the current screen and start a wipe
1542  StartWipe( "wipeMaterial", true );
1543
1544  // immediately complete the wipe to fade out the level transition
1545  // run the wipe to completion
1546  CompleteWipe();
1547  }
1548
1549  // extract the map name from serverinfo
1550  idStr mapString = mapSpawnData.serverInfo.GetString( "si_map" );
1551
1552  idStr fullMapName = "maps/";
1553  fullMapName += mapString;
1554  fullMapName.StripFileExtension();
1555
1556  // shut down the existing game if it is running
1557  UnloadMap();
1558
1559  // don't do the deferred caching if we are reloading the same map
1560  if ( fullMapName == currentMapName ) {
1561  reloadingSameMap = true;
1562  } else {
1563  reloadingSameMap = false;
1564  currentMapName = fullMapName;
1565  }
1566
1567  // note which media we are going to need to load
1568  if ( !reloadingSameMap ) {
1569  declManager->BeginLevelLoad();
1570  renderSystem->BeginLevelLoad();
1571  soundSystem->BeginLevelLoad();
1572  }
1573
1574  uiManager->BeginLevelLoad();
1575  uiManager->Reload( true );
1576
1577  // set the loading gui that we will wipe to
1578  LoadLoadingGui( mapString );
1579
1580  // cause prints to force screen updates as a pacifier,
1581  // and draw the loading gui instead of game draws
1582  insideExecuteMapChange = true;
1583
1584  // if this works out we will probably want all the sizes in a def file although this solution will
1585  // work for new maps etc. after the first load. we can also drop the sizes into the default.cfg
1586  fileSystem->ResetReadCount();
1587  if ( !reloadingSameMap ) {
1588  bytesNeededForMapLoad = GetBytesNeededForMapLoad( mapString.c_str() );
1589  } else {
1590  bytesNeededForMapLoad = 30 * 1024 * 1024;
1591  }
1592
1593  ClearWipe();
1594
1595  // let the loading gui spin for 1 second to animate out
1596  ShowLoadingGui();
1597
1598  // note any warning prints that happen during the load process
1599  common->ClearWarnings( mapString );
1600
1601  // release the mouse cursor
1602  // before we do this potentially long operation
1603  Sys_GrabMouseCursor( false );
1604
1605  // if net play, we get the number of clients during mapSpawnInfo processing
1606  if ( !idAsyncNetwork::IsActive() ) {
1607  numClients = 1;
1608  }
1609
1610  int start = Sys_Milliseconds();
1611
1612  common->Printf( "--------- Map Initialization ---------\n" );
1613  common->Printf( "Map: %s\n", mapString.c_str() );
1614
1615  // let the renderSystem load all the geometry
1616  if ( !rw->InitFromMap( fullMapName ) ) {
1617  common->Error( "couldn't load %s", fullMapName.c_str() );
1618  }
1619
1620  // for the synchronous networking we needed to roll the angles over from
1621  // level to level, but now we can just clear everything
1622  usercmdGen->InitForNewMap();
1623  memset( &mapSpawnData.mapSpawnUsercmd, 0, sizeof( mapSpawnData.mapSpawnUsercmd ) );
1624
1625  // set the user info
1626  for ( i = 0; i < numClients; i++ ) {
1627  game->SetUserInfo( i, mapSpawnData.userInfo[i], idAsyncNetwork::client.IsActive(), false );
1628  game->SetPersistentPlayerInfo( i, mapSpawnData.persistentPlayerInfo[i] );
1629  }
1630
1631  // load and spawn all other entities ( from a savegame possibly )
1632  if ( loadingSaveGame && savegameFile ) {
1633  if ( game->InitFromSaveGame( fullMapName + ".map", rw, sw, savegameFile ) == false ) {
1634  // If the loadgame failed, restart the map with the player persistent data
1635  loadingSaveGame = false;
1636  fileSystem->CloseFile( savegameFile );
1637  savegameFile = NULL;
1638
1639  game->SetServerInfo( mapSpawnData.serverInfo );
1640  game->InitFromNewMap( fullMapName + ".map", rw, sw, idAsyncNetwork::server.IsActive(), idAsyncNetwork::client.IsActive(), Sys_Milliseconds() );
1641  }
1642  } else {
1643  game->SetServerInfo( mapSpawnData.serverInfo );
1644  game->InitFromNewMap( fullMapName + ".map", rw, sw, idAsyncNetwork::server.IsActive(), idAsyncNetwork::client.IsActive(), Sys_Milliseconds() );
1645  }
1646
1647  if ( !idAsyncNetwork::IsActive() && !loadingSaveGame ) {
1648  // spawn players
1649  for ( i = 0; i < numClients; i++ ) {
1650  game->SpawnPlayer( i );
1651  }
1652  }
1653
1654  // actually purge/load the media
1655  if ( !reloadingSameMap ) {
1656  renderSystem->EndLevelLoad();
1657  soundSystem->EndLevelLoad( mapString.c_str() );
1658  declManager->EndLevelLoad();
1659  SetBytesNeededForMapLoad( mapString.c_str(), fileSystem->GetReadCount() );
1660  }
1661  uiManager->EndLevelLoad();
1662
1663  if ( !idAsyncNetwork::IsActive() && !loadingSaveGame ) {
1664  // run a few frames to allow everything to settle
1665  for ( i = 0; i < 10; i++ ) {
1666  game->RunFrame( mapSpawnData.mapSpawnUsercmd );
1667  }
1668  }
1669
1670  common->Printf ("-----------------------------------\n");
1671
1672  int msec = Sys_Milliseconds() - start;
1673  common->Printf( "%6d msec to load %s\n", msec, mapString.c_str() );
1674
1675  // let the renderSystem generate interactions now that everything is spawned
1676  rw->GenerateAllInteractions();
1677
1678  common->PrintWarnings();
1679
1680  if ( guiLoading && bytesNeededForMapLoad ) {
1681  float pct = guiLoading->State().GetFloat( "map_loading" );
1682  if ( pct < 0.0f ) {
1683  pct = 0.0f;
1684  }
1685  while ( pct < 1.0f ) {
1686  guiLoading->SetStateFloat( "map_loading", pct );
1687  guiLoading->StateChanged( com_frameTime );
1688  Sys_GenerateEvents();
1689  UpdateScreen();
1690  pct += 0.05f;
1691  }
1692  }
1693
1694  // capture the current screen and start a wipe
1695  StartWipe( "wipe2Material" );
1696
1697  usercmdGen->Clear();
1698
1699  // start saving commands for possible writeCmdDemo usage
1700  logIndex = 0;
1701  statIndex = 0;
1702  lastSaveIndex = 0;
1703
1704  // don't bother spinning over all the tics we spent loading
1705  lastGameTic = latchedTicNumber = com_ticNumber;
1706
1707  // remove any prints from the notify lines
1708  console->ClearNotifyLines();
1709
1710  // stop drawing the laoding screen
1711  insideExecuteMapChange = false;
1712
1713  Sys_SetPhysicalWorkMemory( -1, -1 );
1714
1715  // set the game sound world for playback
1716  soundSystem->SetPlayingSoundWorld( sw );
1717
1718  // when loading a save game the sound is paused
1719  if ( sw->IsPaused() ) {
1720  // unpause the game sound world
1721  sw->UnPause();
1722  }
1723
1724  // restart entity sound playback
1725  soundSystem->SetMute( false );
1726
1727  // we are valid for game draws now
1728  mapSpawned = true;
1729  Sys_ClearEvents();
1730 }
1731

motorsep

I am not sure where startmap cmd comes from. Never used it neither in Doom 3 nor in BFG.

bitterman

#2
There are several ways to work around this problem.

We can use the command "cmd" "resetdefaults" instead of the command "cmd" "startgame" by adding to the file 'default.cfg' "map /path/to/map".

It's reload default.cfg from mainmenu and loading our map.

But this is a dirty hack.

See Session_menu.cpp for more.

Perhaps the bug is related to the fact that there is not obvious link between the graphical user interfaces (mainmenu, restart etc.).

motorsep

What is the bug though? (you never explain why do you use startgame in the first place)

bitterman

#4
The mod is not contain any original game data.

I need to start my game from mainmenu.gui  via mouse clicking (mainmenu is black screen with two option "Start" & "Exit").

By default original game starts with:

onAction
{
set "cmd" "startgame game/mars_sity1";
}


In my case:

onAction
{
set "cmd" "startgame game/test";
}


gives an error (crash) as describe above.

I think it's to do with missing resources from the original game data (or compiling error).

And I tried debug doom3.exe in MSVC2010E - it's "can't run neo/...game/game.dll".

BielBdeLuna



motorsep

Quote from: bitterman on June 22, 2015, 05:56:05 AM
No, http://ttimo.github.io/doom3.gpl/

You should be using dhewm3, since original Doom 3 code release has a ton of bugs. Also, how does Doom 3 start the game from the menu? Why does it work for Doom 3, but not for you?

bitterman

Quotehow does Doom 3 start the game from the menu?

If you clicking on gui window then it send to engine command ("cmd") "startgame .../..." (".../..." declared by mapDef in *.def).

In my case the problem is in MoveToNewMap() -> SaveGame().

Ok, now tried with dhewm3.

Thanks!

BielBdeLuna

maybe is startgame ".../yourmapname"?

how is .../... defined in defMap?

what does d3 display as an error?

bitterman

guis/mainmenu.gui:

windowDef AnimNewGame {
rect 0, 0, 0, 0
visible 0
notime 1

onTime 0 {
...
}
                        ...
onTime 2400 {
set "cmd" "startgame game/mars_city1" ;
}


def/maps.def:

mapDef game/mars_city1 {
"name" "#str_03050"
"devname" "01-Mars City"
"singleplayer" "1"
"size0" "241381796"
"size1" "241381796"
"size2" "360373649"
"size3" "509824838"
}

BielBdeLuna

and in which path do you have your map?

why not put your map in mapDef as the stock maps?

motorsep

#12
Doom 3 doesn't use #str in the "name", only RoE does. Maybe there is a difference in parsing def ?

Also, why don't you simply run debug build from MSVC and it will show you what happens on crash ?

bitterman

#13
It chash somewhere in gamex86.dll while execute SaveGame() (it's autosave game before start new game). Invalid access memory or so.

Now I try to understand how to game data (lost game data) affected on this process.

If I copy whole 'base' folder from original CD's all my custom staff works fine.


motorsep

That's one of the biggest benefits having no DLLs like in BFG - easy to debug everything :)