void PlayerHandler::setDestination(const int x, const int y, const int direction) const { createOutPacket(CMSG_PLAYER_CHANGE_DEST); outMsg.writeCoordinates(CAST_U16(x), CAST_U16(y), CAST_U8(direction), "destination"); }
void MercenaryHandler::move(const int x, const int y) const { const BeingId id = PlayerInfo::getMercenaryId(); if (id == BeingId_zero) return; createOutPacket(CMSG_HOMMERC_MOVE_TO); outMsg.writeBeingId(id, "mercenary id"); outMsg.writeCoordinates(CAST_U16(x), CAST_U16(y), 1U, "position"); }
SubImage::SubImage(Image *const parent, SDL_Surface *const image, const int x, const int y, const int width, const int height) : Image(image, false), mInternalBounds(), mParent(parent) { if (mParent) { mParent->incRef(); mParent->SDLTerminateAlphaCache(); mHasAlphaChannel = mParent->hasAlphaChannel(); mIsAlphaVisible = mHasAlphaChannel; mAlphaChannel = mParent->SDLgetAlphaChannel(); mSource = parent->getIdPath(); #ifdef DEBUG_IMAGES logger->log("set name2 %p, %s", static_cast<void*>(this), mSource.c_str()); #endif #ifdef DEBUG_BIND_TEXTURE mIdPath = parent->getIdPath(); #endif } else { mHasAlphaChannel = false; mIsAlphaVisible = false; mAlphaChannel = nullptr; } // Set up the rectangle. mBounds.x = CAST_S16(x); mBounds.y = CAST_S16(y); mBounds.w = CAST_U16(width); mBounds.h = CAST_U16(height); if (mParent) { mInternalBounds.x = mParent->mBounds.x; mInternalBounds.y = mParent->mBounds.y; mInternalBounds.w = mParent->mBounds.w; mInternalBounds.h = mParent->mBounds.h; } else { mInternalBounds.x = 0; mInternalBounds.y = 0; mInternalBounds.w = 1; mInternalBounds.h = 1; } mUseAlphaCache = false; }
void BattleGroundRecv::processBattleEmblem2(Net::MessageIn &msg) { const BeingId id = msg.readBeingId("account id"); msg.readString(24, "name"); msg.readInt16("bg id"); const int teamId = msg.readInt16("team id"); Being *const dstBeing = actorManager->findBeing(id); if (dstBeing) dstBeing->setTeamId(CAST_U16(teamId)); }
SubImage::SubImage(Image *const parent, const GLuint image, const int x, const int y, const int width, const int height, const int texWidth, const int texHeight) : Image(image, width, height, texWidth, texHeight), mInternalBounds(), mParent(parent) { if (mParent) mParent->incRef(); // Set up the rectangle. mBounds.x = CAST_S16(x); mBounds.y = CAST_S16(y); mBounds.w = CAST_U16(width); mBounds.h = CAST_U16(height); if (mParent) { mInternalBounds.x = mParent->mBounds.x; mInternalBounds.y = mParent->mBounds.y; mInternalBounds.w = mParent->mBounds.w; mInternalBounds.h = mParent->mBounds.h; mSource = parent->getIdPath(); #ifdef DEBUG_IMAGES logger->log("set name2 %p, %s", static_cast<void*>(this), mSource.c_str()); #endif #ifdef DEBUG_BIND_TEXTURE mIdPath = parent->getIdPath(); #endif } else { mInternalBounds.x = 0; mInternalBounds.y = 0; mInternalBounds.w = 1; mInternalBounds.h = 1; } mIsAlphaVisible = mHasAlphaChannel; }
uint16_t MumbleManager::getMapId(std::string mapName) { uint16_t res = 0; if (mapName.size() != 5 || mapName[3] != '-') { res = getCrc16(mapName); } else { mapName = mapName.substr(0, 3) + mapName[4]; res = CAST_U16(atoi(mapName.c_str())); } return res; }
void MessageOut::writeInt16(const int16_t value, const char *const str) { DEBUGLOG2("writeInt16: " + toStringPrint(CAST_U32( CAST_U16(value))), mPos, str); expand(2); #if SDL_BYTEORDER == SDL_BIG_ENDIAN int16_t swap = SDL_Swap16(value); memcpy(mData + CAST_SIZE(mPos), &swap, sizeof(int16_t)); #else memcpy(mData + CAST_SIZE(mPos), &value, sizeof(int16_t)); #endif mPos += 2; PacketCounters::incOutBytes(2); }
uint16_t MessageIn::readUInt16(const char *const str) { uint16_t value = 0xffU; if (mPos + 2 <= mLength) { #if SDL_BYTEORDER == SDL_BIG_ENDIAN uint16_t swap; memcpy(&swap, mData + CAST_SIZE(mPos), sizeof(uint16_t)); value = SDL_Swap16(swap); #else // SDL_BYTEORDER == SDL_BIG_ENDIAN memcpy(&value, mData + CAST_SIZE(mPos), sizeof(uint16_t)); #endif // SDL_BYTEORDER == SDL_BIG_ENDIAN } DEBUGLOG2("readUInt16: " + toStringPrint(CAST_U32( CAST_U16(value))), mPos, str); mPos += 2; PacketCounters::incInBytes(2); return value; }
void SurfaceGraphics::drawImage(const Image *restrict const image, int dstX, int dstY) restrict2 { FUNC_BLOCK("Graphics::drawImage", 1) // Check that preconditions for blitting are met. if (!mTarget || !image || !image->mSDLSurface) return; const SDL_Rect &imageRect = image->mBounds; SDL_Rect dstRect; SDL_Rect srcRect; dstRect.x = CAST_S16(dstX); dstRect.y = CAST_S16(dstY); srcRect.x = CAST_S16(imageRect.x); srcRect.y = CAST_S16(imageRect.y); srcRect.w = CAST_U16(imageRect.w); srcRect.h = CAST_U16(imageRect.h); #ifdef USE_SDL2 SDL_BlitSurface(image->mSDLSurface, &srcRect, mTarget, &dstRect); #else // USE_SDL2 if (mBlitMode == BlitMode::BLIT_NORMAL) { SDL_BlitSurface(image->mSDLSurface, &srcRect, mTarget, &dstRect); } else { SurfaceImageHelper::combineSurface(image->mSDLSurface, &srcRect, mTarget, &dstRect); }