Exemple #1
0
extern "C" bool RandTileLoadHook() {
	// OSReport("Trying to load...");
	void *buf = RandTileLoader.load("/NewerRes/RandTiles.bin");
	bool LIresult = LoadLevelInfo();
	if (buf == 0) {
		// OSReport("Failed.\n");
		return false;
	} else {
		// OSReport("Successfully loaded RandTiles.bin [%p].\n", buf);
		RandomTileData::instance = (RandomTileData*)buf;
		return LIresult;
	}
}
Exemple #2
0
bool Level::LoadLevelConstants(const char *pszLevelName, IniReader *pini)
{
    if (!LoadLevelInfo(pszLevelName, pini))
        return false;

    // m_fInitialized is to distinguish between just having the level parameters
    // read and having been initialized enough to require some cleanup.

    m_fInitialized = true;

    // Load map

    Status("Load Tile Map...");
    char szT[kcbFilename];
    if (!pini->GetPropertyValue("General", "TileMap", szT, sizeof(szT))) {
        Assert(false);
        return false;
    }

    Size sizPlayfield;
    ggame.GetPlayfieldSize(&sizPlayfield);
    m_ptmap = LoadTileMap(szT, &sizPlayfield);
    Assert(m_ptmap != NULL);
    if (m_ptmap == NULL) {
        Assert(false);
        return false;
    }

    // Init GobMgr

    Size sizMap;
    m_ptmap->GetMapSize(&sizMap);
    Size sizTile;
    m_ptmap->GetTileSize(&sizTile);
    if (!ggobm.Init(sizMap.cx / sizTile.cx, sizMap.cy / sizTile.cy, kcpgobMax)) {
        Assert(false);
        return false;
    }

    // Load terrain map

    Status("Load Terrain Map...");
    if (!pini->GetPropertyValue("General", "TerrainMap", szT, sizeof(szT))) {
        Assert(false);
        return false;
    }
    m_ptrmap = new TerrainMap;
    if (m_ptrmap == NULL) {
        Assert(false);
        return false;
    }
    if (!m_ptrmap->Init(szT)) {
        Assert(false);
        return false;
    }

    // Create fog map.

    Status("Create Fog Map...");
    m_pfogm = new FogMap;
    if (m_pfogm == NULL) {
        Assert(false);
        return false;
    }
    if (!m_pfogm->Init(&sizTile, &sizMap)) {
        Assert(false);
        return false;
    }

    // Load palette

    if (!pini->GetPropertyValue("General", "Palette", szT, sizeof(szT))) {
        Assert(false);
        return false;
    }
    m_ppal = (Palette *)gpakr.MapFile(szT, &m_fmapPalette);
    if (m_ppal == NULL) {
        Assert(false);
        return false;
    }
    strcat(szT, ".shadowmap");
    m_mpiclriclrShadow = (byte *)gpakr.MapFile(szT, &m_fmapShadowMap);

    // Instantiate an OvermindGob for each Computer Player

    Player *pplr = gplrm.GetNextPlayer(NULL);
    for (; pplr != NULL; pplr = gplrm.GetNextPlayer(pplr)) {
#ifdef STRESS
        // Instantiate an Overmind for the human player if we're running stress

        if (gfStress) {
            if ((pplr->GetFlags() & (kfPlrComputer | kfPlrComputerOvermind)) == kfPlrComputer)
                continue;
        } else {
            if (!(pplr->GetFlags() & kfPlrComputerOvermind))
                continue;
        }
#else
        if (!(pplr->GetFlags() & kfPlrComputerOvermind))
            continue;
#endif

        // Instantiate and initialize an OvermindGob

        OvermindGob *pgobOvermind = (OvermindGob *)CreateGob(kgtOvermind);
        if (pgobOvermind == NULL) {
            Assert(false);
            delete pini;
            return false;
        }

        if (!pgobOvermind->Init(NULL)) {
            Assert(false);
            delete pgobOvermind;
            delete pini;
            return false;
        }

        // Who's your daddy?

        pgobOvermind->SetOwner(pplr);
    }

    // Load the Triggers

    Status("Load Triggers...");
    if (!m_tgrm.Init(pini)) {
        Assert(false);
        return false;
    }

    // Load the UnitGroups

    Status("Load UnitGroups...");
    if (!m_ugm.Init(pini)) {
        Assert(false);
        return false;
    }

    return true;
}