W pliku player.h znajdÂĄ:
time_t lastlogin; time_t lastLoginSaved;
i przenie¶ to pod linijkę : public:
W pliku protocol76.cpp znajdÂĄ:
#include "game.h"
i pod tym dodaj:
#include ioplayer.h
ZnajdÂĄ:
void Protocol76::parseTextWindow(NetworkMessage &msg)
i zamień CAłY ParseTextWindow na ten kod:
void Protocol76::parseTextWindow(NetworkMessage &msg) { unsigned long id = msg.GetU32(); std::string new_text = msg.GetString(); if(readItem && windowTextID == id) { readItem->setText(new_text); readItem->releaseThing(); readItem = NULL; } }
Dalej znajdÂĄ:
if(from_x == to_x && from_y == to_y && from_z == to_z) return;
i pod tym dodaj:
if(to_x != 0xFFFF && (itemid == ITEM_PARCEL || itemid == ITEM_LETTER)) { Tile* t = game->getTile(to_x, to_y, to_z); if(t && t->hasItem(ITEM_MAILBOX)) { Item* parcel = dynamic_cast<Item*>(game->getThing(Position(from_x, from_y, from_z), from_stack, player)); if(parcel) { bool canSend = true; bool foundLabel = false; std::string receiver; unsigned int depotid; Container* parcel2 = dynamic_cast<Container*>(parcel); if(parcel2 && itemid == ITEM_PARCEL) { for(int x = 0; x < parcel2->size(); x++) { Item* label = dynamic_cast<Item*>(parcel2->getItem(x)); if(label && label->getID() == ITEM_LABEL) { foundLabel = true; std::string text = label->getText(); std::istringstream iss(text, std::istringstream::in); int i = 0; std::string line[2]; while(std::getline(iss, text,'\n')) { line[i] = text; i++; if(i == 2) break; } receiver = line[0]; std::transform(line[1].begin(), line[1].end(), line[1].begin(), (int(*)(int))tolower); if(line[1] == g_config.getGlobalString("city1","city")) depotid = 1; else if(line[1] == g_config.getGlobalString("city2","jungle")) // add as much as you want depotid = 2; else if(line[1] == g_config.getGlobalString("city3","desert")) // add as much as you want depotid = 3; else if(line[1] == g_config.getGlobalString("city4","paris")) // add as much as you want depotid = 4; else if(line[1] == g_config.getGlobalString("city5","nose")) // add as much as you want depotid = 5; else if(line[1] == g_config.getGlobalString("city6","nose")) // add as much as you want depotid = 6; else if(line[1] == g_config.getGlobalString("city7","nose")) // add as much as you want depotid = 7; else if(line[1] == g_config.getGlobalString("city8","nose")) // add as much as you want depotid = 8; else if(line[1] == g_config.getGlobalString("city9","nose")) // add as much as you want depotid = 9; else if(line[1] == g_config.getGlobalString("city10","nose")) // add as much as you want depotid = 10; else canSend = false; if(!game->isPlayer(receiver)) canSend = false; if(canSend) break; } } } else if(itemid == ITEM_LETTER) { foundLabel = true; std::string text = parcel->getText(); std::istringstream iss(text, std::istringstream::in); int i = 0; std::string line[2]; while(std::getline(iss, text,'\n')) { line[i] = text; i++; if(i == 2) break; } receiver = line[0]; std::transform(line[1].begin(), line[1].end(), line[1].begin(), (int(*)(int))tolower); if(line[1] == g_config.getGlobalString("city1","city")) depotid = 1; else if(line[1] == g_config.getGlobalString("city2","jungle")) // add as much as you want depotid = 2; else if(line[1] == g_config.getGlobalString("city3","desert")) // add as much as you want depotid = 3; else if(line[1] == g_config.getGlobalString("city4","paris")) // add as much as you want depotid = 4; else if(line[1] == g_config.getGlobalString("city5","nose")) // add as much as you want depotid = 5; else if(line[1] == g_config.getGlobalString("city6","nose")) // add as much as you want depotid = 6; else if(line[1] == g_config.getGlobalString("city7","nose")) // add as much as you want depotid = 7; else if(line[1] == g_config.getGlobalString("city8","nose")) // add as much as you want depotid = 8; else if(line[1] == g_config.getGlobalString("city9","nose")) // add as much as you want depotid = 9; else if(line[1] == g_config.getGlobalString("city10","nose")) // add as much as you want depotid = 10; else canSend = false; if(!game->isPlayer(receiver)) canSend = false; } if(canSend && foundLabel) { game->removeThing(player,Position(from_x, from_y, from_z), parcel, true); Player* player = game->getPlayerByName(receiver); if(player) { parcel->setID((itemid == ITEM_LETTER?ITEM_STLETTER:ITEM_STPARCEL)); Container* depot = player->getDepot(depotid); if(depot) depot->addItem(parcel); std::vector<unsigned char> containerlist; containerLayout::const_iterator cit; for(cit = player->getContainers(); cit != player->getEndContainer(); ++cit) { Container* c = cit->second; const char* msg = (itemid == ITEM_PARCEL?"You received a new parcel.":"You received a new letter."); if(c == depot) { player->sendTextMessage(MSG_ADVANCE, msg); player->onItemAddContainer(depot, parcel); break; } if(c->getParent() == depot) { player->sendTextMessage(MSG_ADVANCE, msg); break; } } } else { Protocol76* prot = new Protocol76(0); player = new Player(receiver, prot); parcel->setID((itemid == ITEM_LETTER?ITEM_STLETTER:ITEM_STPARCEL)); IOPlayer::instance()->loadPlayer(player, receiver); Container* depot = player->getDepot(depotid); if(depot) depot->addItem(parcel); player->lastlogin = player->lastLoginSaved; IOPlayer::instance()->savePlayer(player); delete player; } return; } } } }
W pliku [b]game.cpp znajdÂĄ:
#include <iostream> #include <fstream>
jeżeli tego nie masz dodaj pod:
#include <ctype.h>
Na końcu pliku dodaj:
bool Game::isPlayer(const std::string name) { OTSYS_THREAD_LOCK_CLASS lockClass(gameLock, "Game::isPlayer()"); std::stringstream s; s << "data/players/" << name << ".xml"; ifstream namefile(s.str().c_str()); if(namefile.is_open()) { namefile.close(); return true; } return false; }
W pliku game.h znajdÂĄ:
~Game();
i pod tym dodaj:
bool isPlayer(const std::string name);
W pliku const76.h znajdÂĄ:
enum item_t {
i pod tym dodaj:
ITEM_PARCEL = 2595, ITEM_STPARCEL = 2596, ITEM_MAILBOX = 2593, ITEM_MAILBOX2 = 2334, ITEM_MAILBOX3 = 3981, ITEM_LABEL = 2599, ITEM_LETTER = 2597, ITEM_STLETTER = 2598,
W pliku tile.cpp na końcu pliku dodaj:
bool Tile::hasItem(unsigned long id) const { ItemVector::const_iterator iit; for(iit = topItems.begin(); iit != topItems.end(); ++iit) { if((*iit)->getID() == id) return true; } for(iit = downItems.begin(); iit != downItems.end(); ++iit) { if((*iit)->getID() == id) return true; } return false; }
W pliku tile.h pod:
bool removeThing(Thing *thing);
dodaj:
bool hasItem(unsigned long id) const;
Btw. jeżeli używasz YurOTS to znajdÂĄ:
bool Game::isPlayer(std::string name)
i usuń
teraz na końcu pliku dodaj:
bool Game::isPlayer(std::string name) { extern xmlMutexPtr xmlmutex; std::string datadir = g_config.getGlobalString("datadir"); std::string filenamecheck = datadir + "players/" + name + ".xml"; std::transform(filenamecheck.begin(),filenamecheck.end(), filenamecheck.begin(), (int(*)(int))tolower); xmlDocPtr doc; xmlMutexLock(xmlmutex); doc = xmlParseFile(filenamecheck.c_str()); if (doc) { xmlMutexUnlock(xmlmutex); xmlFreeDoc(doc); return true; } else { xmlMutexUnlock(xmlmutex); xmlFreeDoc(doc); return false; } }
(Ten powyższy kod to jest Parcele + Vip List z YurOTS)
by SuperGillis
config.lua:
-- Name city to send parcels & letters (DEPOT ID'S > 1 to 10 < ) city1 = city1 city2 = city2 city3 = city3 city4 = city4 city5 = city5 city6 = city6 city7 = city7 city8 = city8 city9 = city9 city10 = city10
Kod Nie MOj Xd
Offline