/** ****************************************************************************** @file /common/rm/rmmapi.cpp @brief Interface k RMraster @author Vta @version 1.0 ******************************************************************************/ #include "common/rm/rmmapi.h" using namespace World; namespace rm { /// Funkce bezici ve vlastnim vlakne nacitajici mapu int loadMapThr(void * data) { int * b=(int*)data; *b=1; TRM_map_i * RMmapi=(TRM_map_i *)KSendMessage(RQUEUE,MSG_GET_RM_MAP_I,MOD_RM,MOD_RM,NULL); try { RMmapi->loadBuffer(); } catch (E_8K) { GLOBALLOGID(PRIORITY_EXCETION_IN_THREAD, "Exception in loadMapThr"); KSendMessage(RQUEUE,MSG_EXCEPTION_IN_THREAD,MOD_RM,BROADCAST,NULL); } delete(RMmapi); return 0; } void TRM_map_i::prepareGame() { int transfered=0; if (this->threadid==NULL) { this->threadid=SDL_CreateThread(loadMapThr, (void*) &transfered); while (transfered!=1) // cekam, dokud nepredam vse do vlakna - necekam, az to nacte, jen predavam { } } else { GLOBALLOGID(PRIORITY_FATAL, "RMmapi the origin map must be released first"); THROW(E_8K_RM,"RMmapi the origin map must be released first"); } } void TRM_map_i::loadMap(char * filename,int maptype) { this->rmmap->loadMap(filename,maptype); } void TRM_map_i::saveMap(int maptype,char * newname) { if (this->threadid!=NULL) // cekam kdyz se zrovna nacita mapa { SDL_WaitThread(this->threadid, NULL); this->threadid=NULL; } this->rmmap->saveMap(maptype,newname); } void TRM_map_i::getKingdoms(TKingdomInfo *** kingdoms) { this->rmmap->getKingdoms(kingdoms); } void TRM_map_i::setKingdoms(TKingdomInfo ** kingdoms) { this->rmmap->setKingdoms(kingdoms); } void TRM_map_i::getCurrentState(TStateInfo ** state) { this->rmmap->getCurrentState(state); } void TRM_map_i::setCurrentState(TStateInfo * state) { this->rmmap->setCurrentState(state); } void TRM_map_i::getHistoryHexes(World::HISTORY_HEX **** hmap) { this->rmmap->getHistoryHexes(hmap); } void TRM_map_i::setHistoryHexes(World::HISTORY_HEX *** hmap) { this->rmmap->setHistoryHexes(hmap); } HEX * TRM_map_i::getHex(int id) { return this->rmmap->getHex(id); } int TRM_map_i::getHexes(World::HEX *** map) { return this->rmmap->getHexes(map); } void TRM_map_i::setHexes(World::HEX ** map) { this->rmmap->setHexes(map); } void TRM_map_i::getCities(DA ** cities) { this->rmmap->getCities(cities); } void TRM_map_i::setCities(DA * cities) { this->rmmap->setCities(cities); } void TRM_map_i::setLivingUnits(DA * units) { this->rmmap->setLivingUnits(units); } void TRM_map_i::setLivingBuildings(DA * buildings) { this->rmmap->setLivingBuildings(buildings); } void TRM_map_i::getLivingUnits(DA ** units) { this->rmmap->getLivingUnits(units); } void TRM_map_i::getLivingBuildings(DA ** buildings) { this->rmmap->getLivingBuildings(buildings); } void TRM_map_i::getLivingBuilding(World::LIVING_BUILDING ** building,int id) { this->rmmap->getLivingBuilding(building,id); } void TRM_map_i::getLivingUnit(World::LIVING_UNIT ** unit,int id) { this->rmmap->getLivingUnit(unit,id); } void TRM_map_i::getAIPlan(TAIPlan ** plan) { this->rmmap->getAIPlan(plan); } void TRM_map_i::setAIPlan(TAIPlan * plan) { this->rmmap->setAIPlan(plan); } int TRM_map_i::isMapLoaded() { return this->rmmap->isMapLoaded(); } int TRM_map_i::idOfLoadedMap() { return this->rmmap->idOfLoadedMap(); } void TRM_map_i::loadMapNow(int id) { this->rmmap->loadMap(id); } void TRM_map_i::selectMap(int id) { this->rmmap->selectMap(id); } void TRM_map_i::request(int id) { this->rmmap->request(id); } /* void TRM_map_i::requestDep(int id) { this->rmmap->preparemaps(id); } */ void TRM_map_i::loadBuffer() { this->rmmap->loadBuffer(); } void TRM_map_i::freeData() { if (this->threadid!=NULL) // cekam kdyz se zrovna nacita mapa { SDL_WaitThread(this->threadid, NULL); this->threadid=NULL; } this->rmmap->freeMap(); } int TRM_map_i::getMapsCount(int maptype) { return this->rmmap->getMapsCount(maptype); } int TRM_map_i::getMapsMaxId(int maptype) { return this->rmmap->getMapsMaxId(maptype); } int TRM_map_i::addMap(TMapInfo * info, int maptype) { return this->rmmap->addMap(info,maptype); } void TRM_map_i::loadMapsInfo(int maptype,int refresh) { this->rmmap->loadMapsInfo(maptype,refresh); } void TRM_map_i::delMap(int id) { this->rmmap->delMap(id); } /* void TRM_map_i::modifyMap(TMapData * map) { this->rmmap->modifyMap(map); } void TRM_map_i::get(TMapData ** map,int id) { this->rmmap->getMap(map,id); } */ void TRM_map_i::getMapsInfo(DA ** info,int maptype) { this->rmmap->getMapsInfo(info,maptype); } void TRM_map_i::getMapInfo(TMapInfo ** info,int id) { this->rmmap->getMapInfo(info,id); } TRM_map_i::TRM_map_i(TRM_map * globalrmmap) { this->threadid=NULL; this->rmmap=globalrmmap; GLOBALLOGID(PRIORITY_CONFIRM ,"RMmapi was created"); } TRM_map_i::~TRM_map_i() { if (this->threadid!=NULL) { SDL_WaitThread(this->threadid, NULL); this->threadid=NULL; } GLOBALLOGID(PRIORITY_CONFIRM ,"RMmapi was destroyed"); } } // namespace rm