Autor Wiadomość
Naiko
PostWysłany: Czw 21:33, 18 Maj 2006

No no dzięki ale jeśli crashuje otsa to raczej nie założymy ale dzieki za poświęcenie pozytyw dla ciebie Very Happy
Hummel
PostWysłany: Czw 15:35, 18 Maj 2006

dziekuje bardzo ale czemu naiko nie zkomentowal pewnie juz to ogladal...
Habas
PostWysłany: Czw 15:09, 18 Maj 2006

Jak Naiko chciał to ma Razz Aaaa i gratuloje 10 postu Razz
Hummel
PostWysłany: Czw 14:34, 18 Maj 2006

ostatnio rozmawialem z naiko na gg i wspominal on cos o bed system a wiec..oto on:
Odrazu na wstepie mowie ze to nie jest moj bed system.Znalazlem go na tibi.xx.pl i chce tu go zamiescic<ale plagiat nie zabroniony i moze jakis repucik Smile >

w pliku game.cpp na koncu plku dodaj:

Kod:
#ifdef TLM_BEDS 
bool Game::loadBeds(std::string file) 

  xmlDocPtr doc; 
  doc = xmlParseFile(file.c_str()); 
  if (doc){ 
   xmlNodePtr root, p, tmp; 
   root = xmlDocGetRootElement(doc); 
   if (xmlStrcmp(root->name, (const xmlChar*)"beds")) { 
     xmlFreeDoc(doc); 
     return -1; 
   } 
    tmp = root->children; 
    int x,y,z,id; 
    while(tmp){ 
      if (strcmp((char*) tmp->name, "bed")==0){       
        x = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "x")); 
        y = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "y")); 
        z = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "z")); 
        id = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "id")); 
        Position mainPos(x, y, z); 
        Item *mainItem = Item::CreateItem(id);   
        Tile *mainTile = getTile(mainPos.x, mainPos.y, mainPos.z); 
        if (mainTile && mainItem){ 
          Position nextPos(x, y, z); 
          Item *nextItem = Item::CreateItem(id+1); 
          if (id == 1754 || id == 1758 || id == 1762 || id == 1766){ 
            nextPos.y++; 
          } 
          else if(id == 1756 || id == 1760 || id == 1764 || id == 1768){ 
            nextPos.x++; 
          } 
          Tile *nextTile = getTile(nextPos.x, nextPos.y, nextPos.z);     
          if (nextTile && nextItem){ 
            mainTile->addThing(mainItem); 
            mainItem->pos = mainPos; 
            nextTile->addThing(nextItem); 
            nextItem->pos = nextPos; 
          } 
        } 
      } 
      tmp = tmp->next; 
    }       
    xmlFreeDoc(doc); 
    return 0; 
  } 
  return -1; 

std::string Game::getBedSleeper(const Position pos) 

  std::string file="data/beds.xml"; 
  xmlDocPtr doc; 
  doc = xmlParseFile(file.c_str()); 
  if (doc){ 
    xmlNodePtr root, tmp; 
    root = xmlDocGetRootElement(doc);         
    if (xmlStrcmp(root->name, (const xmlChar*)"beds")) { 
      xmlFreeDoc(doc); 
      return "Nobody"; 
    } 
    tmp = root->children; 
    while(tmp){ 
      if (strcmp((const char*) tmp->name, "bed")==0){ 
        int x = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "x")); 
        int y = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "y")); 
        int z = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "z")); 
        if (x == pos.x && y == pos.y && z == pos.z){ 
          return (const char*)xmlGetProp(tmp, (const xmlChar *)"name"); 
        }   
      } 
      tmp = tmp->next; 
    } 
    xmlFreeDoc(doc); 
  } 
  return "Nobody"; 

unsigned int Game::getBedID(const Position pos) 

  std::string file="data/beds.xml"; 
  xmlDocPtr doc; 
  doc = xmlParseFile(file.c_str()); 
  if (doc){ 
    xmlNodePtr root, tmp; 
    root = xmlDocGetRootElement(doc);         
    if (xmlStrcmp(root->name, (const xmlChar*)"beds")) { 
      xmlFreeDoc(doc); 
      return 0; 
    } 
    tmp = root->children; 
    while(tmp){ 
      if (strcmp((const char*) tmp->name, "bed")==0){ 
        int x = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "x")); 
        int y = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "y")); 
        int z = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "z")); 
        if (x == pos.x && y == pos.y && z == pos.z){ 
          return atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "id")); 
        }   
      } 
      tmp = tmp->next; 
    } 
    xmlFreeDoc(doc); 
  } 
  return 0; 


bool Game::changeBed(const Position pos, unsigned int oldid, std::string sleepname) 

  Tile *maintile = getTile(pos.x,pos.y,pos.z); 
  Item *mainitem = dynamic_cast<Item*>(maintile->getThingByStackPos(maintile->getThingCount()-1)); 
  if (mainitem && maintile->isHouse()){ 
    Position tilePos(pos.x, pos.y, pos.z); 
    if (oldid == 1754 || oldid == 1758 || oldid == 1762 || oldid == 1766){ 
      tilePos.y++; 
    } 
    else if(oldid == 1756 || oldid == 1760 || oldid == 1764 || oldid == 1768){ 
      tilePos.x++; 
    } 
    Tile *nexttile = getTile(tilePos.x,tilePos.y,tilePos.z); 
    Item *nextitem = dynamic_cast<Item*>(nexttile->getThingByStackPos(maintile->getThingCount()-1)); 
    if (nextitem && nexttile->isHouse()){   
      if (oldid == 1754 || oldid == 1758){ 
        mainitem->setID(oldid+8); 
      } 
      else if(oldid == 1756){ 
        mainitem->setID(1768); 
      } 
      else if(oldid == 1760){ 
        mainitem->setID(1764); 
      } 
      else if(oldid == 1762 || oldid == 1766){ 
        mainitem->setID(oldid-8); 
      } 
      else if(oldid == 1764){ 
        mainitem->setID(1760); 
      } 
      else if(oldid == 1768){ 
        mainitem->setID(1756); 
      } 
      nextitem->setID(mainitem->getID()+1); 
      creatureBroadcastTileUpdated(pos); 
      creatureBroadcastTileUpdated(tilePos); 
       
      std::string file="data/beds.xml"; 
      xmlDocPtr doc; 
      doc = xmlParseFile(file.c_str()); 
      if (doc){ 
        xmlNodePtr root, tmp; 
        root = xmlDocGetRootElement(doc);         
        if (xmlStrcmp(root->name, (const xmlChar*)"beds")) { 
          xmlFreeDoc(doc); 
          return false; 
        } 
        Position bedPos[1000];// 1000 = number of beds 
        unsigned int id[1000]; 
        std::string name[1000]; 
        int i = 0; 
        tmp = root->children; 
        while(tmp){ 
          if (strcmp((const char*) tmp->name, "bed")==0){ 
            i++; 
            bedPos[i].x = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "x"  )); 
            bedPos[i].y = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "y"  )); 
            bedPos[i].z = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "z"  )); 
            id[i]    = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "id" )); 
            name[i]   = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "name")); 
            if (bedPos[i] == pos){ 
              id[i]  = mainitem->getID(); 
              name[i] = sleepname; 
            } 
          } 
          tmp = tmp->next; 
        } 
        doc = xmlNewDoc((const xmlChar*)"1.0"); 
        doc->children = xmlNewDocNode(doc, NULL, (const xmlChar*)"beds", NULL); 
       root = doc->children; 
       
        std::stringstream sb; 
        for(int x = 1; x <= i; x++){ 
          tmp = xmlNewNode(NULL,(const xmlChar*)"bed"); 
          sb << bedPos[x].x; xmlSetProp(tmp, (const xmlChar*) "x" ,  (const xmlChar*)sb.str().c_str()); sb.str(""); 
          sb << bedPos[x].y; xmlSetProp(tmp, (const xmlChar*) "y" ,  (const xmlChar*)sb.str().c_str()); sb.str(""); 
          sb << bedPos[x].z; xmlSetProp(tmp, (const xmlChar*) "z" ,  (const xmlChar*)sb.str().c_str()); sb.str(""); 
          sb << id[x];    xmlSetProp(tmp, (const xmlChar*) "id",  (const xmlChar*)sb.str().c_str()); sb.str(""); 
          sb << name[x];   xmlSetProp(tmp, (const xmlChar*) "name", (const xmlChar*)sb.str().c_str()); sb.str(""); 
          xmlAddChild(root, tmp); 
        } 
       xmlSaveFile(file.c_str(), doc); 
       xmlFreeDoc(doc); 
        return true; 
      } 
    } 
  } 
  return false; 

Position Game::getBedPos(std::string name) 

  std::string file="data/beds.xml"; 
  xmlDocPtr doc; 
  doc = xmlParseFile(file.c_str()); 
  if (doc){ 
    xmlNodePtr root, tmp; 
    root = xmlDocGetRootElement(doc);         
    if (xmlStrcmp(root->name, (const xmlChar*)"beds")) { 
      xmlFreeDoc(doc); 
      return Position(0xFFFF,0xFFFF,0xFF); 
    } 
    tmp = root->children; 
    while(tmp){ 
      if (strcmp((const char*) tmp->name, "bed")==0){ 
        std::string sleepname = (const char*)xmlGetProp(tmp, (const xmlChar *)"name"); 
        if (sleepname == name){ 
          int x = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "x")); 
          int y = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "y")); 
          int z = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "z")); 
          return Position(x,y,z); 
        }   
      } 
      tmp = tmp->next; 
    } 
    xmlFreeDoc(doc); 
  } 
  return Position(0xFFFF,0xFFFF,0xFF); 


void Game::sendMagicEffect(const Position pos, unsigned char type) 

  SpectatorVec list; 
  SpectatorVec::iterator it; 
  getSpectators(Range(pos, true), list); 
   for(it = list.begin(); it != list.end(); ++it) { 
    Player* spectator = dynamic_cast<Player*>(*it); 
    if (spectator){ 
      spectator->sendMagicEffect(pos, type); 
    } 
  } 

#endif //TLM_BEDS 




W pliku game.h pod linijką:

Kod:
~Game(); 



dodaj:

Kod:
#ifdef TLM_BEDS 
        std::string getBedSleeper(const Position pos); 
          unsigned int getBedID(const Position pos); 
          Position getBedPos(std::string name); 
   
          bool changeBed(const Position pos, unsigned int oldid, std::string sleepname); 
          bool loadBeds(std::string file); 
#endif //TLM BEDS 



W pliku item.cpp na końcu pliku dodaj

Kod:
#ifdef TLM_BEDS 
bool Item::isBed() 

if(id == 1754 || id == 1755 || id == 1756 || id == 1757 || id == 1758 || id == 1759 || id == 1760 || id == 1761 || id == 1762 || id == 1763 || id == 1764 || id == 1765 || id == 1766 || id == 1767 || id == 1768 || id == 1769) 
return true; 
else return false; 

#endif //TLM_BEDS 




W pliku item.h pod:

Kod:
bool isDecaying; 



dodaj:

Kod:

#ifdef TLM_BEDS     
    bool isBed(); 
#endif //TLM_BEDS 




W pliku otserv.cpp pod:

Kod:
#ifdef TLM_HOUSE_SYSTEM 
    std::cout << ":: Loading houses.xml...            "; 
    if (!Houses::Load(&g_game)) 
    { 
        ErrorMessage("Could not load houses!"); 
        return -1; 
    } 
    std::cout << "[done]" << std::endl; 
#endif //TLM_HOUSE_SYSTEM 



Dodaj:
Kod:

#ifdef TLM_BEDS 
 std::cout << ":: Loading beds.xml...              "; 
 if(g_game.loadBeds("data/beds.xml")){; 
 ErrorMessage("Could not load data/beds.xml!"); 
 return -1; 

  std::cout << "[done]" << std::endl; 
#endif //TLM_BEDS 



W pliku player.cpp pod:

Kod:
internal_ping = 0; 


dodaj:

Kod:
#ifdef TLM_BEDS 
    lastlogout = 0; 
#endif //TLM_BEDS 



Na końcu pliku dodaj:

Kod:
#ifdef TLM_BEDS 
void Player::sendLogout() 

  client->logout(); 


    void Player::sendKick() 

    this->kicked = true; 
    client->sendKick();     


   
bool Player::isSleeping() 

  std::string file="data/beds.xml"; 
  xmlDocPtr doc; 
  doc = xmlParseFile(file.c_str()); 
  if (doc){ 
    xmlNodePtr root, tmp; 
    root = xmlDocGetRootElement(doc);         
    if (xmlStrcmp(root->name, (const xmlChar*)"beds")) { 
      xmlFreeDoc(doc); 
      return false; 
    } 
    tmp = root->children; 
    while(tmp){ 
      if (strcmp((const char*) tmp->name, "bed")==0){ 
        std::string sleepname = (const char*)xmlGetProp(tmp, (const xmlChar *)"name"); 
        if (sleepname == this->name){ 
          return true; 
        }   
      } 
      tmp = tmp->next; 
    } 
    xmlFreeDoc(doc); 
  } 
  return false; 

#endif //TLM_BEDS 



W pliku player.h
pod linijką:

Kod:
public: 



dodaj:

Kod:
#ifdef TLM_BEDS 
time_t lastlogout; 
bool isSleeping(); 
void sendLogout(); 
         bool kicked; 
    void sendKick(); 
#endif //TLM_BEDS 



W pliku protocol76.cpp NAD:

Kod:
#ifdef TLM_HOUSE_SYSTEM 
        Tile* doorTile = game->getTile(LookPos); 



dodaj:

Kod:
#ifdef TLM_BEDS     
       if(item->isBed()){ 
    Position pos(LookPos.x, LookPos.y, LookPos.z); 
    std::stringstream bedtext;         
    bedtext << "You see a bed"/*<< item->getName()*/ 
    << ".\n " << game->getBedSleeper(pos) << " is sleeping there."; 
    AddTextMessage(newmsg, MSG_INFO, 
    bedtext.str().c_str()); 
    sendNetworkMessage(&newmsg); 
            return; 
    } 
#endif //TLM_BEDS 



Teraz naciśnij ALT + P przejdź do zakładki PARAMETERS i w sub tabeli C++ compiler dodaj na końcu tabelki:


Kod:
-DTLM_BEDS




te bed systemy crashujom otsa jak slyszalem ale jak naiko chcial to ma...
chociaz juz wole manafluidy niz to bo to sie oplaca jak amsz w h**a many a nie tak ze bedziesz sie kladl i wstawal i tak wkolko i wkolko jak masz 100many......



ps. to juz 10 post no to zaczynamy jazde gdzies tak to 1k meyby Smile