Facebook
From Gruff Hummingbird, 8 Years ago, written in C++.
This paste is a reply to sdfsdf from Trivial Penguin - view diff
Embed
Download Paste or View Raw
Hits: 433
  1. void Game::thingMoveInternal(Creature *creature, unsigned short from_x, unsigned short from_y, unsigned char from_z,
  2.         unsigned char stackPos, unsigned short itemid, unsigned short to_x, unsigned short to_y, unsigned char to_z, unsigned char count)
  3. {
  4.         Tile *fromTile = getTile(from_x, from_y, from_z);
  5.         if(!fromTile)
  6.                 return;
  7.  
  8.         Tile *toTile   = getTile(to_x, to_y, to_z);
  9.         /*
  10.         if(!toTile){
  11.                 if(dynamic_cast<Player*>(player))
  12.                         dynamic_cast<Player*>(player)->sendCancelWalk("Sorry, not possible...");
  13.                 return;
  14.         }
  15.         */
  16.  
  17.         Thing *thing = fromTile->getThingByStackPos(stackPos);
  18.  
  19. #ifdef __DEBUG__
  20.                                 //                              std::cout << "moving"
  21.                                 /*
  22.                                 << ": from_x: "<< (int)from_x << ", from_y: "<< (int)from_y << ", from_z: "<< (int)from_z
  23.                                 << ", stackpos: "<< (int)stackPos
  24.                                 << ", to_x: "<< (int)to_x << ", to_y: "<< (int)to_y << ", to_z: "<< (int)to_z
  25.                                 */
  26.                                 //<< std::endl;
  27. #endif
  28.  
  29.         if (!thing)
  30.                 return;
  31.  
  32.         Item* item = dynamic_cast<Item*>(thing);
  33.         Creature* creatureMoving = dynamic_cast<Creature*>(thing);
  34.         Player* playerMoving = dynamic_cast<Player*>(creatureMoving);
  35.         Player* player = dynamic_cast<Player*>(creature);
  36.  
  37.         Position oldPos;
  38.         oldPos.x = from_x;
  39.         oldPos.y = from_y;
  40.         oldPos.z = from_z;
  41.  
  42. #ifdef TP_TRASH_BINS
  43.         if(toTile)
  44.         {
  45.                 Thing *tothing = toTile->getThingByStackPos(stackPos);
  46.                 Item *toItem = dynamic_cast<Item*>(tothing);
  47.  
  48.                 if(item && toItem && !playerMoving && !creature && toItem->isDeleter())
  49.                 {
  50.                         fromTile->removeThing(item);
  51.                         this->FreeThing(item);
  52.                         //creatureBroadcastTileUpdated(oldPos);
  53.                         sendRemoveThing(player, item->pos, item, stackPos);
  54.                         return;
  55.                 }
  56.     }
  57. #endif //TP_TRASH_BINS
  58.  
  59.         // *** Creature moving itself to a non-tile
  60.         if(!toTile && creatureMoving && creatureMoving == creature){
  61.                 //change level begin
  62.                 Tile* downTile = getTile(to_x, to_y, to_z+1);
  63.                 //diagonal begin
  64.                 if(!downTile)
  65.                 {
  66.  
  67.                 if (toTile) {
  68. ItemVector::iterator brn;
  69. for (brn = toTile->downItems.begin(); brn != toTile->downItems.end(); brn++)
  70.         {
  71. if (creatureMoving && (*brn)->getID() == 1492 && creature != thing )
  72. {
  73. creature->sendCancel("Sorry, not possible");
  74. return;
  75. }
  76.         }
  77.                                                         }
  78.  
  79.  
  80.                         if(player) {
  81.                                 player->sendTextMessage(MSG_SMALLINFO, "Sorry, not possible.");
  82.                                 player->sendCancelWalk();
  83.                         }
  84.  
  85.                         return;
  86.                 }