Beispiel #1
0
void DynamicZone::makeDynamicZone()
{

	ZoneInfo* pTemplateZoneInfo = g_pZoneInfoManager->getZoneInfo(m_TemplateZoneID);
	Assert(pTemplateZoneInfo != NULL);

	char temp[128];

	// make zone info
	ZoneInfo* pZoneInfo = new ZoneInfo();
	pZoneInfo->setZoneID(m_ZoneID);
	pZoneInfo->setZoneGroupID(pTemplateZoneInfo->getZoneGroupID());
	pZoneInfo->setZoneType(pTemplateZoneInfo->getZoneType());
	pZoneInfo->setZoneLevel(pTemplateZoneInfo->getZoneLevel());
	pZoneInfo->setZoneAccessMode(pTemplateZoneInfo->getZoneAccessMode());
	pZoneInfo->setZoneOwnerID(pTemplateZoneInfo->getZoneOwnerID());
	pZoneInfo->setPayPlay(pTemplateZoneInfo->isPayPlay());
	pZoneInfo->setPremiumZone(pTemplateZoneInfo->isPremiumZone());
	pZoneInfo->setPKZone(pTemplateZoneInfo->isPKZone());
	pZoneInfo->setNoPortalZone(pTemplateZoneInfo->isNoPortalZone());
	pZoneInfo->setHolyLand(pTemplateZoneInfo->isHolyLand());
	pZoneInfo->setAvailable(pTemplateZoneInfo->isAvailable());
	pZoneInfo->setOpenLevel(pTemplateZoneInfo->getOpenLevel());
	pZoneInfo->setSMPFilename(pTemplateZoneInfo->getSMPFilename());
	pZoneInfo->setSSIFilename(pTemplateZoneInfo->getSSIFilename());
	sprintf(temp, "%s%u", pTemplateZoneInfo->getFullName().c_str(), m_ZoneID);
	pZoneInfo->setFullName(temp);
	sprintf(temp, "%s%u", pTemplateZoneInfo->getShortName().c_str(), m_ZoneID);
	pZoneInfo->setShortName(temp);

	// add zone info to g_pZoneInfoManager
	g_pZoneInfoManager->addZoneInfo(pZoneInfo);

	// make zone and add to ZoneGroup
	Zone* pZone = new Zone(pZoneInfo->getZoneID());
	Assert(pZone != NULL);

	// DynamicZone set to Zone
	pZone->setDynamicZone(this);

	// m_pZone setting
	m_pZone = pZone;

	// init zone
	pZone->init();
	// init DynamicZone
	init();

	// set ZoneGroup
	ZoneGroup* pZoneGroup = g_pZoneGroupManager->getZoneGroup(pZoneInfo->getZoneGroupID());
	Assert(pZoneGroup != NULL);

	pZone->setZoneGroup(pZoneGroup);
	pZoneGroup->addZone(pZone);
}
Beispiel #2
0
void loadmap(Zone& area, Map& level, Player& player1, Surface& images)
{ 
    int mapnum, floornum;
    bool stairs;
    int playx,playy;
    //load world and set initial values the first time through
    if (player1.get_map() == -1) {
        
        srand(time(NULL));
        mapnum = area.get_id();          
        floornum = 0;  
        area.init();
        level = area.zones[mapnum].floors[floornum]; 
        playx = level.get_begin_x() * TILEW;
        playy = level.get_begin_y() * TILEH;      
        player1.put_stairs(1);          
    }    
    //load a new map if the player has changed maps midplay
    if (player1.get_map() >= 0) {
        mapnum = player1.get_destmap();
        floornum = player1.get_destfloor();
        if (floornum < 0) {
            floornum = 0;
            player1.put_stairs(1);   
            mapnum = area.get_id(); 
            playx = area.zones[player1.get_map()].get_x() * TILEW;
            playy = (area.zones[player1.get_map()].get_y() + 1) * TILEH;
        }        
        area.zones[player1.get_map()].floors[player1.get_floor()] = level; 
    }
    
    level = area.zones[mapnum].floors[floornum]; 
    level.set_rendered(0); //area is not yet rendered for graphics
    if (area.zones[mapnum].floors[floornum].get_type() == TOWN){
        playx = MAPW / 2 * TILEW;
        playy = (MAPH - 2) * TILEH;
    }
    if (area.zones[mapnum].floors[floornum].get_type() == DUNGEON){    
        stairs = player1.get_stairs();
        if (stairs == 0) {
            playx = level.get_end_x() * TILEW;
            playy = level.get_end_y() * TILEH;
        }
        if (stairs == 1) {
            playx = level.get_begin_x() * TILEW;
            playy = level.get_begin_y() * TILEH;
        }    
    }
    player1.put_coor(playx, playy);    
    player1.put_map(mapnum);
    player1.put_floor(floornum);
    
    
    //load appropriate spritesheet for this kind of level
    switch(level.get_type())
    {
        case DUNGEON:
            images.tilesheet = load_bitmaps("data/images/dungeon.jpg");
            break;
        case TOWN:
            images.tilesheet = load_bitmaps("data/images/town.jpg");
            break;
        case FOREST:
            images.tilesheet = load_bitmaps("data/images/forest.jpg");
            break;
    }    
};
Beispiel #3
0
//--------------------------------------------------------------------------------
//
// load data from database
//
// 데이타베이스에 연결해서 ZoneGroup 을 로드해온다.
//
//--------------------------------------------------------------------------------
void ZoneGroupManager::load ()
	throw(Error)
{
	__BEGIN_TRY
	__BEGIN_DEBUG
    cout << "[ZoneGroupManager] Loading..." << endl;
	Statement* pStmt = NULL;
	list<ZoneGroupID_t> ZoneGroupIDList;

	// 먼저 존 그룹 아이디들을 읽는다.
	BEGIN_DB
	{
		pStmt = g_pDatabaseManager->getConnection("DARKEDEN")->createStatement();
		Result* pResult = pStmt->executeQuery("SELECT ZoneGroupID FROM ZoneGroupInfo ORDER BY ZoneGroupID");

		while (pResult->next())
		{
			ZoneGroupID_t ID = pResult->getInt(1);
			ZoneGroupIDList.push_back(ID);
		}

		SAFE_DELETE(pStmt);
	}
	END_DB(pStmt)


	list<ZoneGroupID_t>::iterator itr = ZoneGroupIDList.begin();
	for (; itr != ZoneGroupIDList.end(); itr++)
	{
		ZoneGroupID_t ID = (*itr);

		// 해당하는 ID의 존 그룹을 생성하고, 매니저에다 더한다.
		ZoneGroup* pZoneGroup = new ZoneGroup(ID);
		ZonePlayerManager* pZonePlayerManager = new ZonePlayerManager();
		pZonePlayerManager->setZGID(ID);
		pZoneGroup->setZonePlayerManager(pZonePlayerManager);
		addZoneGroup(pZoneGroup);

		// 이 존 그룹에 속하는 존의 정보를 읽어들이고, 초기화해야 한다.
		BEGIN_DB
		{
			pStmt = g_pDatabaseManager->getConnection("DARKEDEN")->createStatement();
			//Result* pResult = pStmt->executeQuery("SELECT ZoneID FROM ZoneInfo WHERE ZoneGroupID = %d", ID);
			Result* pResult = pStmt->executeQuery(
					"SELECT ZoneID FROM ZoneInfo WHERE ZoneGroupID = %d ORDER BY ZoneID", (int)ID);

			while (pResult->next())
			{
				ZoneID_t zoneID = pResult->getInt(1);

				// 존 객체를 생성, 초기화한 후, 존그룹에 추가한다.
				Zone* pZone = new Zone(zoneID);
				Assert(pZone != NULL);
								
				pZone->setZoneGroup(pZoneGroup);

				pZoneGroup->addZone(pZone);

				//--------------------------------------------------------------------------------
				// 순서에 유의할 것.
				// 내부에서 NPC 를 로딩하게 되는데.. AtFirst-SetPosition 컨디션-액션을 수행할때
				// ZoneGroupManager 에 접근하게 된다. 따라서, 먼저 ZGM에 추가한 후 초기화를 해야 한다.
				//--------------------------------------------------------------------------------

				//printf("\n@@@@@@@@@@@@@@@ [%d]th ZONE INITIALIZATION START @@@@@@@@@@@@@@@\n", zoneID);

				pZone->init();

				//printf("\n@@@@@@@@@@@@@@@ [%d]th ZONE INITIALIZATION SUCCESS @@@@@@@@@@@@@@@\n", zoneID);
			}

			SAFE_DELETE(pStmt);
		}
		END_DB(pStmt)
	}

	ZoneGroupIDList.clear();

	/*


	Statement* pStmt1 = NULL;

	try 
	{
		pStmt1 = g_pDatabaseManager->getConnection("DARKEDEN")->createStatement();

		// ZoneGroupID 를 읽어온다.
		//Result* pResult1 = pStmt1->executeQuery("SELECT ZoneGroupID FROM ZoneGroupInfo ORDER BY ZoneGroupID");
		Result* pResult1 = pStmt1->executeQuery("SELECT ZoneGroupID FROM ZoneGroupInfo");

		while (pResult1->next()) 
		{
			ZoneGroupID_t zoneGroupID = pResult1->getInt(1);

			// ZoneGroup 객체와 ZonePlayerManager 객체를 생성한다.
			ZoneGroup* pZoneGroup = new ZoneGroup(zoneGroupID);
			ZonePlayerManager* pZonePlayerManager = new ZonePlayerManager();
			pZoneGroup->setZonePlayerManager(pZonePlayerManager);

			// 존그룹을 존그룹매니저에 추가한다.
			addZoneGroup(pZoneGroup);
	
			// 특정 ZoneGroupID 를 가진 존 정보를 읽어온다.
			Statement* pStmt2 = NULL;
			
			BEGIN_DB
			{
				pStmt2 = g_pDatabaseManager->getConnection("DARKEDEN")->createStatement();
				Result* pResult2 = pStmt2->executeQuery("SELECT ZoneID FROM ZoneInfo WHERE ZoneGroupID = %d", zoneGroupID);
		
				while (pResult2->next()) 
				{
					__BEGIN_DEBUG

					ZoneID_t zoneID = pResult2->getInt(1);

					// 존 객체를 생성, 초기화한 후, 존그룹에 추가한다.
					Zone* pZone = new Zone (zoneID);
					Assert(pZone != NULL);
									
					pZone->setZoneGroup(pZoneGroup);

					pZoneGroup->addZone(pZone);

					//--------------------------------------------------------------------------------
					// 순서에 유의할 것.
					// 내부에서 NPC 를 로딩하게 되는데.. AtFirst-SetPosition 컨디션-액션을 수행할때
					// ZoneGroupManager 에 접근하게 된다. 따라서, 먼저 ZGM에 추가한 후 초기화를 해야 한다.
					//--------------------------------------------------------------------------------

					printf("\n@@@@@@@@@@@@@@@ [%d]th ZONE INITIALIZATION START @@@@@@@@@@@@@@@\n", zoneID);

					pZone->init();

					printf("\n@@@@@@@@@@@@@@@ [%d]th ZONE INITIALIZATION SUCCESS @@@@@@@@@@@@@@@\n", zoneID);

					__END_DEBUG
				}

				SAFE_DELETE(pStmt2);
			}
			END_DB(pStmt2)
		}

		SAFE_DELETE(pStmt1);
	} 
	catch (SQLQueryException & sqe) 
	{
		SAFE_DELETE(pStmt1);
		throw Error(sqe.toString());
	}
	*/
    cout << "[ZoneGroupManager] Loaded." << endl;
	__END_DEBUG
	__END_CATCH
}