diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-03-18 22:13:37 +0200 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-03-18 22:13:37 +0200 |
commit | f4792bc06f21335fc2d1171d937ea7645ca0c253 (patch) | |
tree | c7b11cf81f254f5b9ed2f5dbfe127649abc7545a /src/net | |
parent | f98d003e354a1792117b7cbc771d1dd91475a156 (diff) | |
download | manaverse-f4792bc06f21335fc2d1171d937ea7645ca0c253.tar.gz manaverse-f4792bc06f21335fc2d1171d937ea7645ca0c253.tar.bz2 manaverse-f4792bc06f21335fc2d1171d937ea7645ca0c253.tar.xz manaverse-f4792bc06f21335fc2d1171d937ea7645ca0c253.zip |
Fix most conversions except manaserv net code and some other code.
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/download.cpp | 2 | ||||
-rw-r--r-- | src/net/manaserv/playerhandler.cpp | 4 | ||||
-rw-r--r-- | src/net/manaserv/playerhandler.h | 4 | ||||
-rw-r--r-- | src/net/playerhandler.h | 4 | ||||
-rw-r--r-- | src/net/tmwa/beinghandler.cpp | 53 | ||||
-rw-r--r-- | src/net/tmwa/charserverhandler.cpp | 5 | ||||
-rw-r--r-- | src/net/tmwa/guildhandler.cpp | 8 | ||||
-rw-r--r-- | src/net/tmwa/inventoryhandler.cpp | 7 | ||||
-rw-r--r-- | src/net/tmwa/npchandler.cpp | 16 | ||||
-rw-r--r-- | src/net/tmwa/partyhandler.cpp | 4 | ||||
-rw-r--r-- | src/net/tmwa/playerhandler.cpp | 26 | ||||
-rw-r--r-- | src/net/tmwa/playerhandler.h | 4 | ||||
-rw-r--r-- | src/net/tmwa/specialhandler.cpp | 16 | ||||
-rw-r--r-- | src/net/tmwa/tradehandler.cpp | 5 | ||||
-rw-r--r-- | src/net/worldinfo.h | 2 |
15 files changed, 91 insertions, 69 deletions
diff --git a/src/net/download.cpp b/src/net/download.cpp index aa2793ddb..1badf1763 100644 --- a/src/net/download.cpp +++ b/src/net/download.cpp @@ -90,7 +90,7 @@ unsigned long Download::fadler32(FILE *file) // Calculate Adler-32 checksum char *buffer = static_cast<char*>(malloc(fileSize)); - const size_t read = fread(buffer, 1, fileSize, file); + const uInt read = static_cast<uInt>(fread(buffer, 1, fileSize, file)); unsigned long adler = adler32(0L, Z_NULL, 0); adler = adler32(static_cast<uInt>(adler), reinterpret_cast<Bytef*>(buffer), read); diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp index 9ea030862..292915581 100644 --- a/src/net/manaserv/playerhandler.cpp +++ b/src/net/manaserv/playerhandler.cpp @@ -340,7 +340,7 @@ void PlayerHandler::stopAttack() } -void PlayerHandler::emote(int emoteId _UNUSED_) +void PlayerHandler::emote(Uint8 emoteId _UNUSED_) { // TODO } @@ -359,7 +359,7 @@ void PlayerHandler::decreaseAttribute(int attr) gameServerConnection->send(msg); } -void PlayerHandler::increaseSkill(int skillId _UNUSED_) +void PlayerHandler::increaseSkill(unsigned short skillId _UNUSED_) { // Not used atm } diff --git a/src/net/manaserv/playerhandler.h b/src/net/manaserv/playerhandler.h index 7b75b88cb..79909d31c 100644 --- a/src/net/manaserv/playerhandler.h +++ b/src/net/manaserv/playerhandler.h @@ -54,11 +54,11 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler void attack(int id, bool keep = false); void stopAttack(); - void emote(int emoteId); + void emote(Uint8 emoteId); void increaseAttribute(int attr); void decreaseAttribute(int attr); - void increaseSkill(int skillId); + void increaseSkill(unsigned short skillId); void pickUp(FloorItem *floorItem); void setDirection(char direction); diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h index 1862dea58..524340458 100644 --- a/src/net/playerhandler.h +++ b/src/net/playerhandler.h @@ -40,13 +40,13 @@ class PlayerHandler virtual void stopAttack() = 0; - virtual void emote(int emoteId) = 0; + virtual void emote(Uint8 emoteId) = 0; virtual void increaseAttribute(int attr) = 0; virtual void decreaseAttribute(int attr) = 0; - virtual void increaseSkill(int skillId) = 0; + virtual void increaseSkill(unsigned short skillId) = 0; virtual void pickUp(FloorItem *floorItem) = 0; diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index f066db0bd..05f10854a 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -359,7 +359,8 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) msg.readInt16(); dstBeing->setStunMode(stunMode); - dstBeing->setStatusEffectBlock(0, (statusEffects >> 16) & 0xffff); + dstBeing->setStatusEffectBlock(0, static_cast<Uint16>( + (statusEffects >> 16) & 0xffff)); dstBeing->setStatusEffectBlock(16, statusEffects & 0xffff); break; @@ -649,7 +650,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) switch (type) { case 0: // change race - dstBeing->setSubtype(id); + dstBeing->setSubtype(static_cast<Uint16>(id)); break; case 1: // eAthena LOOK_HAIR dstBeing->setSpriteID(SPRITE_HAIR, id *-1); @@ -661,15 +662,18 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) player_node->imitateOutfit(dstBeing, SPRITE_SHIELD); break; case 3: // Change lower headgear for eAthena, pants for us - dstBeing->setSprite(SPRITE_BOTTOMCLOTHES, id, color, id2); + dstBeing->setSprite(SPRITE_BOTTOMCLOTHES, id, color, + static_cast<unsigned char>(id2)); player_node->imitateOutfit(dstBeing, SPRITE_BOTTOMCLOTHES); break; case 4: // Change upper headgear for eAthena, hat for us - dstBeing->setSprite(SPRITE_HAT, id, color, id2); + dstBeing->setSprite(SPRITE_HAT, id, color, + static_cast<unsigned char>(id2)); player_node->imitateOutfit(dstBeing, SPRITE_HAT); break; case 5: // Change middle headgear for eathena, armor for us - dstBeing->setSprite(SPRITE_TOPCLOTHES, id, color, id2); + dstBeing->setSprite(SPRITE_TOPCLOTHES, id, color, + static_cast<unsigned char>(id2)); player_node->imitateOutfit(dstBeing, SPRITE_TOPCLOTHES); break; case 6: // eAthena LOOK_HAIR_COLOR @@ -678,35 +682,45 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) break; case 8: // eAthena LOOK_SHIELD if (!config.getBoolValue("hideShield")) - dstBeing->setSprite(SPRITE_SHIELD, id, color, id2); + { + dstBeing->setSprite(SPRITE_SHIELD, id, color, + static_cast<unsigned char>(id2)); + } player_node->imitateOutfit(dstBeing, SPRITE_SHIELD); break; case 9: // eAthena LOOK_SHOES - dstBeing->setSprite(SPRITE_SHOE, id, color, id2); + dstBeing->setSprite(SPRITE_SHOE, id, color, + static_cast<unsigned char>(id2)); player_node->imitateOutfit(dstBeing, SPRITE_SHOE); break; case 10: // LOOK_GLOVES - dstBeing->setSprite(SPRITE_GLOVES, id, color, id2); + dstBeing->setSprite(SPRITE_GLOVES, id, color, + static_cast<unsigned char>(id2)); player_node->imitateOutfit(dstBeing, SPRITE_GLOVES); break; case 11: // LOOK_CAPE - dstBeing->setSprite(SPRITE_CAPE, id, color, id2); + dstBeing->setSprite(SPRITE_CAPE, id, color, + static_cast<unsigned char>(id2)); player_node->imitateOutfit(dstBeing, SPRITE_CAPE); break; case 12: - dstBeing->setSprite(SPRITE_MISC1, id, color, id2); + dstBeing->setSprite(SPRITE_MISC1, id, color, + static_cast<unsigned char>(id2)); player_node->imitateOutfit(dstBeing, SPRITE_MISC1); break; case 13: - dstBeing->setSprite(SPRITE_MISC2, id, color, id2); + dstBeing->setSprite(SPRITE_MISC2, id, color, + static_cast<unsigned char>(id2)); player_node->imitateOutfit(dstBeing, SPRITE_MISC2); break; case 14: - dstBeing->setSprite(SPRITE_EVOL1, id, color, id2); + dstBeing->setSprite(SPRITE_EVOL1, id, color, + static_cast<unsigned char>(id2)); player_node->imitateOutfit(dstBeing, SPRITE_EVOL1); break; case 15: - dstBeing->setSprite(SPRITE_EVOL2, id, color, id2); + dstBeing->setSprite(SPRITE_EVOL2, id, color, + static_cast<unsigned char>(id2)); player_node->imitateOutfit(dstBeing, SPRITE_EVOL2); break; default: @@ -955,14 +969,9 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) int dir = dstBeing->calcDirection(dstX, dstY); if (dir && dstBeing->getDirection() != dir) - { - dstBeing->setDirectionDelayed(dir); -// dstBeing->clearPath(); -// dstBeing->reset(); - } + dstBeing->setDirectionDelayed(static_cast<Uint8>(dir)); } - if (player_node->getCurrentAction() != Being::STAND) player_node->imitateAction(dstBeing, Being::STAND); if (player_node->getDirection() != dstBeing->getDirection()) @@ -1040,7 +1049,8 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) } dstBeing->setStunMode(stunMode); - dstBeing->setStatusEffectBlock(0, (statusEffects >> 16) & 0xffff); + dstBeing->setStatusEffectBlock(0, static_cast<Uint16>( + (statusEffects >> 16) & 0xffff)); dstBeing->setStatusEffectBlock(16, statusEffects & 0xffff); if (msg.getId() == SMSG_PLAYER_MOVE @@ -1105,7 +1115,8 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) msg.readInt8(); // Unused? dstBeing->setStunMode(stunMode); - dstBeing->setStatusEffectBlock(0, (statusEffects >> 16) & 0xffff); + dstBeing->setStatusEffectBlock(0, static_cast<Uint16>( + (statusEffects >> 16) & 0xffff)); dstBeing->setStatusEffectBlock(16, statusEffects & 0xffff); break; diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp index 2265afb84..c714c6043 100644 --- a/src/net/tmwa/charserverhandler.cpp +++ b/src/net/tmwa/charserverhandler.cpp @@ -82,7 +82,10 @@ void CharServerHandler::handleMessage(Net::MessageIn &msg) msg.skip(2); // Length word int slots = msg.readInt16(); if (slots > 0 && slots < 30) - loginData.characterSlots = slots; + { + loginData.characterSlots + = static_cast<short unsigned int>(slots); + } bool version = msg.readInt8() == 1 && serverVersion > 0; msg.skip(17); // Unused diff --git a/src/net/tmwa/guildhandler.cpp b/src/net/tmwa/guildhandler.cpp index ed738df4f..198dafeca 100644 --- a/src/net/tmwa/guildhandler.cpp +++ b/src/net/tmwa/guildhandler.cpp @@ -136,7 +136,7 @@ void GuildHandler::handleMessage(Net::MessageIn &msg) msg.readInt8(); // Unused std::string guildName = msg.readString(24); - Guild *g = Guild::getGuild(guildId); + Guild *g = Guild::getGuild(static_cast<short int>(guildId)); if (!g) break; @@ -219,7 +219,7 @@ void GuildHandler::handleMessage(Net::MessageIn &msg) _("Guild castle: %s"), castle.c_str()), BY_SERVER); } - Guild *g = Guild::getGuild(guildId); + Guild *g = Guild::getGuild(static_cast<short int>(guildId)); if (!g) break; g->setName(name); @@ -703,8 +703,8 @@ void GuildHandler::chat(int guildId _UNUSED_, const std::string &text) std::string str = player_node->getName() + " : " + text; MessageOut msg(CMSG_GUILD_MESSAGE); - msg.writeInt16(str.size() + 4); - msg.writeString(str, str.length()); + msg.writeInt16(static_cast<Uint16>(str.size() + 4)); + msg.writeString(str, static_cast<int>(str.length())); } void GuildHandler::memberList(int guildId _UNUSED_) diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp index 203edaa26..e5ccc9110 100644 --- a/src/net/tmwa/inventoryhandler.cpp +++ b/src/net/tmwa/inventoryhandler.cpp @@ -158,7 +158,8 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg) { int number, flag; int index, amount, itemId, equipType, arrow, refine; - int identified, cards[4], itemType; + int cards[4], itemType; + unsigned char identified; Inventory *inventory = 0; if (player_node) inventory = PlayerInfo::getInventory(); @@ -632,14 +633,14 @@ void InventoryHandler::moveItem(int source, int slot, int amount, if (source == Inventory::INVENTORY && destination == Inventory::STORAGE) { MessageOut outMsg(CMSG_MOVE_TO_STORAGE); - outMsg.writeInt16(slot + INVENTORY_OFFSET); + outMsg.writeInt16(static_cast<Sint16>(slot + INVENTORY_OFFSET)); outMsg.writeInt32(amount); } else if (source == Inventory::STORAGE && destination == Inventory::INVENTORY) { MessageOut outMsg(CSMG_MOVE_FROM_STORAGE); - outMsg.writeInt16(slot + STORAGE_OFFSET); + outMsg.writeInt16(static_cast<Sint16>(slot + STORAGE_OFFSET)); outMsg.writeInt32(amount); } } diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp index f085da68c..f70e8cd03 100644 --- a/src/net/tmwa/npchandler.cpp +++ b/src/net/tmwa/npchandler.cpp @@ -189,9 +189,9 @@ void NpcHandler::integerInput(int npcId, int value) void NpcHandler::stringInput(int npcId, const std::string &value) { MessageOut outMsg(CMSG_NPC_STR_RESPONSE); - outMsg.writeInt16(value.length() + 9); + outMsg.writeInt16(static_cast<Sint16>(value.length() + 9)); outMsg.writeInt32(npcId); - outMsg.writeString(value, value.length()); + outMsg.writeString(value, static_cast<int>(value.length())); outMsg.writeInt8(0); // Prevent problems with string reading } @@ -228,16 +228,16 @@ void NpcHandler::buyItem(int beingId _UNUSED_, int itemId, if (serverVersion > 0) { outMsg.writeInt16(10); // One item (length of packet) - outMsg.writeInt16(amount); - outMsg.writeInt16(itemId); + outMsg.writeInt16(static_cast<Sint16>(amount)); + outMsg.writeInt16(static_cast<Sint16>(itemId)); outMsg.writeInt8(color); outMsg.writeInt8(0); } else { outMsg.writeInt16(8); // One item (length of packet) - outMsg.writeInt16(amount); - outMsg.writeInt16(itemId); + outMsg.writeInt16(static_cast<Sint16>(amount)); + outMsg.writeInt16(static_cast<Sint16>(itemId)); } } @@ -245,8 +245,8 @@ void NpcHandler::sellItem(int beingId _UNUSED_, int itemId, int amount) { MessageOut outMsg(CMSG_NPC_SELL_REQUEST); outMsg.writeInt16(8); // One item (length of packet) - outMsg.writeInt16(itemId + INVENTORY_OFFSET); - outMsg.writeInt16(amount); + outMsg.writeInt16(static_cast<Sint16>(itemId + INVENTORY_OFFSET)); + outMsg.writeInt16(static_cast<Sint16>(amount)); } void NpcHandler::endShopping(int beingId _UNUSED_) diff --git a/src/net/tmwa/partyhandler.cpp b/src/net/tmwa/partyhandler.cpp index bd9766c4b..10d2a20f0 100644 --- a/src/net/tmwa/partyhandler.cpp +++ b/src/net/tmwa/partyhandler.cpp @@ -538,8 +538,8 @@ void PartyHandler::kick(const std::string &name) void PartyHandler::chat(const std::string &text) { MessageOut outMsg(CMSG_PARTY_MESSAGE); - outMsg.writeInt16(text.length() + 4); - outMsg.writeString(text, text.length()); + outMsg.writeInt16(static_cast<Sint16>(text.length() + 4)); + outMsg.writeString(text, static_cast<int>(text.length())); } void PartyHandler::requestPartyMembers() diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp index 55908093f..6078dd761 100644 --- a/src/net/tmwa/playerhandler.cpp +++ b/src/net/tmwa/playerhandler.cpp @@ -137,7 +137,8 @@ static const char *randomDeathMessage() N_("You're pining for the fjords.") }; - const int random = rand() % (sizeof(deadMsg) / sizeof(deadMsg[0])); + const int random = static_cast<int>(rand() % (sizeof(deadMsg) + / sizeof(deadMsg[0]))); return gettext(deadMsg[random]); } @@ -228,10 +229,12 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg) Map *map = game->getCurrentMap(); if (map) { - scrollOffsetX = (x - player_node->getTileX()) - * map->getTileWidth(); - scrollOffsetY = (y - player_node->getTileY()) - * map->getTileHeight(); + scrollOffsetX = static_cast<float>((x + - player_node->getTileX()) + * map->getTileWidth()); + scrollOffsetY = static_cast<float>((y + - player_node->getTileY()) + * map->getTileHeight()); } } @@ -260,7 +263,8 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg) switch (type) { case 0x0000: - player_node->setWalkSpeed(Vector(value, value, 0)); + player_node->setWalkSpeed(Vector(static_cast<float>( + value), static_cast<float>(value), 0)); PlayerInfo::setStatBase(WALK_SPEED, value); PlayerInfo::setStatMod(WALK_SPEED, 0); break; @@ -644,7 +648,7 @@ void PlayerHandler::stopAttack() MessageOut outMsg(CMSG_PLAYER_STOP_ATTACK); } -void PlayerHandler::emote(int emoteId) +void PlayerHandler::emote(Uint8 emoteId) { MessageOut outMsg(CMSG_PLAYER_EMOTE); outMsg.writeInt8(emoteId); @@ -655,7 +659,7 @@ void PlayerHandler::increaseAttribute(int attr) if (attr >= STR && attr <= LUK) { MessageOut outMsg(CMSG_STAT_UPDATE_REQUEST); - outMsg.writeInt16(attr); + outMsg.writeInt16(static_cast<Sint16>(attr)); outMsg.writeInt8(1); } } @@ -665,7 +669,7 @@ void PlayerHandler::decreaseAttribute(int attr _UNUSED_) // Supported by eA? } -void PlayerHandler::increaseSkill(int skillId) +void PlayerHandler::increaseSkill(unsigned short skillId) { if (PlayerInfo::getAttribute(SKILL_POINTS) <= 0) return; @@ -693,7 +697,9 @@ void PlayerHandler::setDirection(char direction) void PlayerHandler::setDestination(int x, int y, int direction) { MessageOut outMsg(CMSG_PLAYER_CHANGE_DEST); - outMsg.writeCoordinates(x, y, direction); + outMsg.writeCoordinates(static_cast<short unsigned int>(x), + static_cast<short unsigned int>(y), + static_cast<unsigned char>(direction)); } void PlayerHandler::changeAction(Being::Action action) diff --git a/src/net/tmwa/playerhandler.h b/src/net/tmwa/playerhandler.h index 095a00d94..f77bd11b8 100644 --- a/src/net/tmwa/playerhandler.h +++ b/src/net/tmwa/playerhandler.h @@ -46,11 +46,11 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler void attack(int id, bool keep = false); void stopAttack(); - void emote(int emoteId); + void emote(Uint8 emoteId); void increaseAttribute(int attr); void decreaseAttribute(int attr); - void increaseSkill(int skillId); + void increaseSkill(unsigned short skillId); void pickUp(FloorItem *floorItem); void setDirection(char direction); diff --git a/src/net/tmwa/specialhandler.cpp b/src/net/tmwa/specialhandler.cpp index f632248ab..586f5fe00 100644 --- a/src/net/tmwa/specialhandler.cpp +++ b/src/net/tmwa/specialhandler.cpp @@ -256,24 +256,24 @@ void SpecialHandler::use(int id _UNUSED_) void SpecialHandler::use(int id, int level, int beingId) { MessageOut outMsg(CMSG_SKILL_USE_BEING); - outMsg.writeInt16(level); - outMsg.writeInt16(id); - outMsg.writeInt16(beingId); + outMsg.writeInt16(static_cast<Sint16>(level)); + outMsg.writeInt16(static_cast<Sint16>(id)); + outMsg.writeInt16(static_cast<Sint16>(beingId)); } void SpecialHandler::use(int id, int level, int x, int y) { MessageOut outMsg(CMSG_SKILL_USE_POSITION); - outMsg.writeInt16(level); - outMsg.writeInt16(id); - outMsg.writeInt16(x); - outMsg.writeInt16(y); + outMsg.writeInt16(static_cast<Sint16>(level)); + outMsg.writeInt16(static_cast<Sint16>(id)); + outMsg.writeInt16(static_cast<Sint16>(x)); + outMsg.writeInt16(static_cast<Sint16>(y)); } void SpecialHandler::use(int id, const std::string &map) { MessageOut outMsg(CMSG_SKILL_USE_MAP); - outMsg.writeInt16(id); + outMsg.writeInt16(static_cast<Sint16>(id)); outMsg.writeString(map, 16); } diff --git a/src/net/tmwa/tradehandler.cpp b/src/net/tmwa/tradehandler.cpp index 581031f23..b7cf70661 100644 --- a/src/net/tmwa/tradehandler.cpp +++ b/src/net/tmwa/tradehandler.cpp @@ -208,7 +208,7 @@ void TradeHandler::handleMessage(Net::MessageIn &msg) else { tradeWindow->addItem2(type, false, amount, refine, - identify, false); + static_cast<unsigned char>(identify), false); } } } @@ -325,7 +325,8 @@ void TradeHandler::addItem(Item *item, int amount) return; MessageOut outMsg(CMSG_TRADE_ITEM_ADD_REQUEST); - outMsg.writeInt16(item->getInvIndex() + INVENTORY_OFFSET); + outMsg.writeInt16(static_cast<Sint16>( + item->getInvIndex() + INVENTORY_OFFSET)); outMsg.writeInt32(amount); } diff --git a/src/net/worldinfo.h b/src/net/worldinfo.h index 3e0548336..b02e9fa21 100644 --- a/src/net/worldinfo.h +++ b/src/net/worldinfo.h @@ -31,7 +31,7 @@ struct WorldInfo int address; std::string name; short port; - short online_users; + int online_users; std::string updateHost; }; |