void Pickable::load(TCODZip &zip){
    bool hasTargetSelector = zip.getInt();
    bool hasEffect = zip.getInt();
    if(hasTargetSelector){
        selector = new TargetSelector(TargetSelector::CLOSEST_MONSTER,0);
        selector->load(zip);
    }
    if(hasEffect){
        effect = Effect::create(zip);
    }
}
void
Gui::Load(TCODZip& zip) {
    int numberOfMessages = zip.getInt();

    while(numberOfMessages > 0) {
        char* text = (char*)zip.getString();
        TCODColor color = zip.getColor();

        Message(color, text);

        numberOfMessages--;
    }
}
void Map::save(TCODZip &zip, NodeType type){
    zip.putInt(seed);
    for(int i = 0; i < width * height; i++){
        zip.putInt(tiles[i].explored);
        //zip.putInt(tiles[i].walkable);
        //zip.putInt(tiles[i].inFOV);
    }

    zip.putInt(actors.size());
    for(Actor **it = actors.begin(); it != actors.end(); it++){
        (*it)->save(zip);
    }

    zip.putInt(nextLevel != NULL);
    zip.putInt(prevLevel != NULL);

    if(nextLevel && (type == ROOT || type == BELOW_ROOT)){
        zip.putInt(nextLevel->width);
        zip.putInt(nextLevel->height);
        nextLevel->save(zip, BELOW_ROOT);
    }
    if(prevLevel && (type == ROOT || type == ABOVE_ROOT)){
        zip.putInt(prevLevel->width);
        zip.putInt(prevLevel->height);
        prevLevel->save(zip, ABOVE_ROOT);
    }
}
Beispiel #4
0
void clBuilding::Load(TCODZip &file,VecLoad &bonusdata)
{
     mytile=GetFromLoad(file.getInt(),bonusdata);
    if(mytile==NULL)
        throw "Error loading file";
    int bid=file.getInt();
    t=BTManager::Get().GetTemplate((BuildingID)bid);
    if(t==NULL)
        throw "Error loading building template";
    mypic=file.getInt();
    data=file.getInt();
    int matid=file.getInt();
    mat=MaterialManager::Get().GetMaterial(MATT_ALL,matid);
}
void
Container::Load(TCODZip& zip) {
    size = zip.getInt();
    int numberOfallActors = zip.getInt();

    while(numberOfallActors > 0) {
        Actor* actor = new Actor(0, 0);
        actor->Load(zip);

        inventory.push(actor);

        numberOfallActors--;
    }
}
void Map::load(TCODZip &zip, NodeType type){
    seed = zip.getInt();
    init(false);
    for(int i = 0; i < width * height; i++){
        tiles[i].explored = zip.getInt();
        //tiles[i].walkable = zip.getInt();
        //tiles[i].inFOV = zip.getInt();
    }

    int nbActors = zip.getInt();
    while(nbActors > 0){
        Actor *actor = new Actor(0, 0, 0, NULL, TCODColor::white);
        actor->load(zip);
        actors.push(actor);
        nbActors--;
    }

    bool hasNextLevel = zip.getInt();
    bool hasPrevLevel = zip.getInt();

    if(hasNextLevel && (type == ROOT || type == BELOW_ROOT)){
        int newWidth = zip.getInt();
        int newHeight = zip.getInt();
        nextLevel = new Map(newWidth, newHeight, NULL, this);
        nextLevel->load(zip, BELOW_ROOT);
    }
    if(hasPrevLevel && (type == ROOT || type == ABOVE_ROOT)){
        int newWidth = zip.getInt();
        int newHeight = zip.getInt();
        prevLevel = new Map(newWidth, newHeight, this, NULL);
        prevLevel->load(zip, ABOVE_ROOT);
    }
}
Beispiel #7
0
void Engine::Load(void)
{
    engine.gui_->menu_.Clear();
    engine.gui_->menu_.AddItem(Menu::NEW_GAME, "New game");
    if (TCODSystem::fileExists("game.sav")) {
        engine.gui_->menu_.AddItem(Menu::CONTINUE, "Continue");
    }
    engine.gui_->menu_.AddItem(Menu::EXIT, "Exit");

    Menu::MenuItemCode menuItem = engine.gui_->menu_.Pick();
    if ((menuItem == Menu::EXIT) || (menuItem == Menu::NONE )) {
        // Exit or window closed
        exit(0);
    } else if (menuItem == Menu::NEW_GAME) {
        // New game
        engine.Term();
        engine.Init();
    } else {
        TCODZip zip;
        // continue a saved game
        engine.Term();
        zip.loadFromFile("game.sav");
        // load the map
        int32_t width = zip.getInt();
        int32_t height = zip.getInt();
        map_ = new Map(width, height);
        map_->Load(zip);
        // then the player
        player_ = new Actor(0, 0, 0, NULL, TCODColor::white);
        actors_.push(player_);
        player_->Load(zip);
        // then all other actors
        int32_t nbActors = zip.getInt();
        while (nbActors > 0) {
            Actor *actor = new Actor(0, 0, 0, NULL, TCODColor::white);
            actor->Load(zip);
            actors_.push(actor);
            nbActors--;
        }
        // finally the message log
        gui_->Load(zip);
        // to force FOV recomputation
        gameStatus = STARTUP;
    }
}
Beispiel #8
0
void Actor::Save(TCODZip &zip)
{
    zip.putInt(x_);
    zip.putInt(y_);
    zip.putInt(ch_);
    zip.putColor(&col_);
    zip.putString(name_);
    zip.putInt(blocks_);
    zip.putInt(attacker_ != NULL);
    zip.putInt(destructible_ != NULL);
    zip.putInt(ai_ != NULL);
    zip.putInt(pickable_ != NULL);
    zip.putInt(container_ != NULL);
    if (attacker_ != NULL) attacker_->Save(zip);
    if (destructible_ != NULL) destructible_->Save(zip);
    if (ai_ != NULL) ai_->Save(zip);
    if (pickable_ != NULL) pickable_->Save(zip);
    if (container_ != NULL) container_->Save(zip);
}
Beispiel #9
0
void Actor::save(TCODZip &zip) {
	zip.putInt(x);
	zip.putInt(y);
	zip.putInt(ch);
	zip.putColor(&col);
	zip.putString(name);
	zip.putInt(blocks);
	zip.putInt(attacker != NULL);
	zip.putInt(destructible != NULL);
	zip.putInt(ai != NULL);
	zip.putInt(pickable != NULL);
	zip.putInt(container != NULL);
	
	if (attacker) attacker->save(zip);
	if (destructible) destructible->save(zip);
	if (ai) ai->save(zip);
	if (pickable) pickable->save(zip);
	if (container) container->save(zip);
}
Beispiel #10
0
void Fireball::save(TCODZip &zip) {
	zip.putInt(type);
	zip.putFloat(range);
	zip.putFloat(aoe);
	zip.putFloat(damage);
	zip.putInt(stacks);
	zip.putInt(stackSize);
	zip.putInt(value);
}
Beispiel #11
0
void DamagingAura::save(TCODZip &zip){
	zip.putInt(stat);
	zip.putInt(totalDuration);
	zip.putInt(duration);
	zip.putInt(bonus);
	zip.putInt(life);
	zip.putInt(radius);
	zip.putInt(smart);
}
Beispiel #12
0
void Weapon::load(TCODZip &zip) {
	equipped = zip.getInt();
	slot = (SlotType)zip.getInt();
	stacks = zip.getInt();
	stackSize = zip.getInt();
	value = zip.getInt();
	int numBonus = zip.getInt();
	for(int i = 0; i < numBonus; i++){
		ItemBonus *bon = new ItemBonus(ItemBonus::NOBONUS,0);
		bon->load(zip);
		bonus.push(bon);
	}
	ItemReq *req = new ItemReq(ItemReq::NOREQ,0);
	req->load(zip);
	requirement = req;
	diceNum = zip.getInt();
	diceType = zip.getInt();
	critMult = zip.getInt();
	critRange = zip.getInt();
	wType = (WeaponType)zip.getInt();
}
void
Engine::Save() {
	if(player->destructible->IsDead()) {
		TCODSystem::deleteFile("game.sav");
	}
	else {
		TCODZip zip;

		zip.putInt(SAVEGAME_VERSION);

		zip.putInt(map->width);
		zip.putInt(map->height);
		map->Save(zip);

		player->Save(zip);

		zip.putInt(allActors.size() - 2);

		for(Actor** it = allActors.begin(); it != allActors.end(); ++it) {
			if(*it != player) {
				(*it)->Save(zip);
			}
		}

		gui->Save(zip);

		zip.saveToFile("game.sav");
	}
}
Beispiel #14
0
void Destructible::save(TCODZip &zip) {
	zip.putFloat(maxHp);
	zip.putFloat(hp);
	zip.putFloat(baseDefense);
	zip.putFloat(totalDefense);
	zip.putString(corpseName);
	zip.putInt(xp);
}
Beispiel #15
0
void Destructible::load(TCODZip &zip) {
	maxHp = zip.getFloat();
	hp = zip.getFloat();
	baseDefense = zip.getFloat();
	totalDefense = zip.getFloat();
	corpseName = strdup(zip.getString());
	xp = zip.getInt();
}
void Destructible::load(TCODZip &zip) {
	maxHp = zip.getFloat();
	hp = zip.getFloat();
	defense = zip.getFloat();
	corpseName = _strdup(zip.getString());
	maxAp = zip.getInt();
	ap = zip.getInt();
}
void Destructible::save(TCODZip &zip) {
	zip.putFloat(maxHp);
	zip.putFloat(hp);
	zip.putFloat(defense);
	zip.putString(corpseName);
	zip.putInt(maxAp);
	zip.putInt(ap);
}
Beispiel #18
0
void DamagingAura::load(TCODZip &zip){
	totalDuration = zip.getInt();
	duration = zip.getInt();
	bonus = zip.getInt();
	life = (LifeStyle)zip.getInt();
	radius = zip.getInt();
	smart = zip.getInt();
}
Beispiel #19
0
void Fireball::load(TCODZip &zip) {
	range = zip.getFloat();
	aoe = zip.getFloat();
	damage = zip.getFloat();
	stacks = zip.getInt();
	stackSize = zip.getInt();
	value = zip.getInt();
}
Beispiel #20
0
void LightningBolt::save(TCODZip &zip) {
	zip.putInt(type);
	zip.putFloat(range);
	zip.putFloat(damage);
	zip.putInt(stacks);
	zip.putInt(stackSize);
	zip.putInt(value);
}
Beispiel #21
0
void Confuser::save(TCODZip &zip) {
	zip.putInt(type);
	zip.putInt(nbTurns);
	zip.putFloat(range);
	zip.putInt(stacks);
	zip.putInt(stackSize);
	zip.putInt(value);
}
Beispiel #22
0
void Poison::save(TCODZip &zip) {
	zip.putInt(type);
	zip.putFloat(tick);
	zip.putInt(duration);
	zip.putInt(stacks);
	zip.putInt(stackSize);
	zip.putInt(value);
}
Beispiel #23
0
void clBuilding::Save(TCODZip &file)
{
    file.putChar(CL_BUILDING);
    file.putInt(mytile->GetSave()->num);
    file.putInt(t->GetBuildingID());
    file.putInt(mypic);
    file.putInt(data);
    file.putInt(mat->ID);
}
Beispiel #24
0
void Equipment::save(TCODZip &zip) {
	zip.putInt(type);
	zip.putInt(equipped);
	zip.putInt(slot);
	zip.putInt(stacks);
	zip.putInt(stackSize);
	zip.putInt(value);
	zip.putInt(bonus.size());
	for (int i = 0; i < bonus.size(); i++) {
		bonus.get(i)->save(zip);
	}
	requirement->save(zip);
}
Beispiel #25
0
void Engine::Save(void)
{
    if (player_->destructible_->IsDead()) {
        TCODSystem::deleteFile("game.sav");
    } else {
        TCODZip zip;
        // save the map
        zip.putInt(map_->width_);
        zip.putInt(map_->height_);
        map_->Save(zip);
        // save the player
        player_->Save(zip);
        // then all the other actors
        zip.putInt(actors_.size()-1);
        for (Actor **it = actors_.begin(); it != actors_.end(); it++) {
            if (*it != player_) {
                (*it)->Save(zip);
            }
        }
        // finally the message log
        gui_->Save(zip);
        zip.saveToFile("game.sav");
    }
}
Beispiel #26
0
void Engine::save() {
  if (player->destructible->isDead() ){
    TCODSystem::deleteFile("game.sav");
  }else {
    TCODZip zip;
    //save the map
    zip.putInt(map->width);
    zip.putInt(map->height);
    map->save(zip);
    //then the player
    player->save(zip);
    //All the other actors
    zip.putInt(actors.size()-1);
    for (Actor **iterator=actors.begin(); iterator!=actors.end();
           iterator++){
      if(*iterator != player){
        (*iterator)->save(zip);
      }
    }
    //Save the logs
    gui->save(zip);
    zip.saveToFile("game.sav");
  }
}
Beispiel #27
0
void Tile::LoadStack(TCODZip &file)
{
    char c=file.getChar();
    if (c)
    {
        if (!stack)
            stack=new ItemStack();
        stack->Load(file);
    }
    else
    {
        if (stack)
            delete stack;
        stack=NULL;
    }
}
Beispiel #28
0
void Equipment::load(TCODZip &zip) {
	equipped = zip.getInt();
	slot = (SlotType)zip.getInt();
	stacks = zip.getInt();
	stackSize = zip.getInt();
	value = zip.getInt();
	int nbBonus = zip.getInt();
	for (int i = 0; i <nbBonus; i++) {
		ItemBonus *bon = new ItemBonus(ItemBonus::NOBONUS,0);
		bon->load(zip);
		bonus.push(bon);
	}
	ItemReq *req = new ItemReq(ItemReq::NOREQ,0);
	req->load(zip);
	requirement = req;
}
Beispiel #29
0
void LightningBolt::save(TCODZip &zip)
{
	zip.putInt(LIGHTNING_BOLT);
	zip.putFloat(range);
	zip.putFloat(damage);
}
Beispiel #30
0
void LightningBolt::load(TCODZip &zip)
{
	range=zip.getFloat();
	damage=zip.getFloat();
}