IE::point Region::Position() const { IE::point point = { int16(fRegion->use_point_x), int16(fRegion->use_point_y) }; return point; }
void CUser::ChatTargetSelect(Packet & pkt) { uint8 type = pkt.read<uint8>(); // TO-DO: Replace this with an enum // Attempt to find target player in-game if (type == 1) { Packet result(WIZ_CHAT_TARGET, type); std::string strUserID; pkt >> strUserID; if (strUserID.empty() || strUserID.size() > MAX_ID_SIZE) return; CUser *pUser = g_pMain->GetUserPtr(strUserID.c_str(), TYPE_CHARACTER); if (pUser == NULL || pUser == this) { result << int16(0); } /* TO-DO: Implement PM blocking else if (pUser->isBlockingPMs()) { result << int16(-1); } */ else { m_sPrivateChatUser = pUser->GetSocketID(); result << int16(1) << pUser->m_pUserData.m_id; } Send(&result); }
void CUser::MerchantItemCancel(Packet & pkt) { Packet result(WIZ_MERCHANT, uint8(MERCHANT_ITEM_CANCEL)); _MERCH_DATA *pMerch = nullptr; _ITEM_DATA *pItem = nullptr; uint8 bSrcPos = pkt.read<uint8>(); /* if (this == nullptr) result << int16(-1);*/ // Invalid source position if (bSrcPos >= MAX_MERCH_ITEMS) result << int16(-2); // There's no item in that list..? else if ((pMerch = &m_arMerchantItems[bSrcPos])->nNum == 0) result << int16(-3); // Check to make sure we've got a valid stack else if (pMerch->sCount + (pItem = &m_sItemArray[pMerch->bOriginalSlot])->sCount > HAVE_MAX) result << int16(-3); // custom error else { pItem->nNum = pMerch->nNum; pItem->sCount = pMerch->sCount; pItem->sDuration = pMerch->sDuration; pItem->nSerialNum = pMerch->nSerialNum; // NOTE: Stackable items will have an issue with this. memset(pMerch, 0, sizeof(_MERCH_DATA)); result << int16(1) << bSrcPos; } Send(&result); }
void CUser::MerchantItemCancel(Packet & pkt) { Packet result(WIZ_MERCHANT, uint8(MERCHANT_ITEM_CANCEL)); uint8 bSrcPos = pkt.read<uint8>(); /* if (this == NULL) result << int16(-1);*/ // Invalid source position if (bSrcPos >= MAX_MERCH_ITEMS) result << int16(-2); // There's no item in that list..? else if (m_arSellingItems[bSrcPos].nNum == 0) result << int16(-3); // Check to make sure we've got a valid stack else if (m_arSellingItems[bSrcPos].sCount + m_pUserData->m_sItemArray[m_arSellingItems[bSrcPos].bOriginalSlot].sCount > HAVE_MAX) result << int16(-3); // custom error else { // NOTE: As we don't remove the item from the inventory (I think we should, though), we can just unset the item in the selling list. memset(&m_arSellingItems[bSrcPos], 0, sizeof(_MERCH_DATA)); result << int16(1) << bSrcPos; } Send(&result); }
void RoomContainer::MouseOver(uint16 x, uint16 y) { const uint16 kScrollingStep = 64; uint16 horizBorderSize = 35; uint32 vertBorderSize = 40; // TODO: Less hardcoding of the window number Window* window = GUI::Get()->GetWindow(1); if (window != NULL) { horizBorderSize += window->Width(); } sint16 scrollByX = 0; sint16 scrollByY = 0; if (x <= horizBorderSize) scrollByX = -kScrollingStep; else if (x >= fViewPort.w - horizBorderSize) scrollByX = kScrollingStep; if (y <= vertBorderSize) scrollByY = -kScrollingStep; else if (y >= fViewPort.h - vertBorderSize) scrollByY = kScrollingStep; IE::point point = { int16(x), int16(y) }; ConvertToArea(point); _UpdateCursor(x, y, scrollByX, scrollByY); // TODO: This screams for improvements if (fWed != NULL) { int32 cursor = -1; fMouseOverObject = _ObjectAtPoint(point, cursor); if (cursor != -1) GUI::Get()->SetCursor(cursor); } else if (fWorldMap != NULL) { for (uint32 i = 0; i < fWorldMap->CountAreaEntries(); i++) { AreaEntry& area = fWorldMap->AreaEntryAt(i); GFX::rect areaRect = area.Rect(); if (rect_contains(areaRect, point)) { ConvertFromArea(areaRect); ConvertToScreen(areaRect); //char* toolTip = area.TooltipName(); //RenderString(toolTip, GraphicsEngine::Get()->ScreenSurface()); //free(toolTip); GraphicsEngine::Get()->ScreenBitmap()->StrokeRect(areaRect, 600); break; } } } IE::point newAreaOffset = fAreaOffset; newAreaOffset.x += scrollByX; newAreaOffset.y += scrollByY; SetAreaOffset(newAreaOffset); }
//------------------------------------------------------------------------ inline void cell_aa::set(int cx, int cy, int c, int a) { x = int16(cx); y = int16(cy); packed_coord = (cy << 16) + cx; cover = c; area = a; }
void PlayerLogger::LogDamage(bool done, uint16 damage, uint16 heal, ObjectGuid const & unitGuid, uint16 spell) { if (!IsLoggingActive(done ? PLAYER_LOGMASK_DAMAGE_DONE : PLAYER_LOGMASK_DAMAGE_GET)) return; PlayerLogDamage log = PlayerLogDamage(sWorld.GetUptime()); log.dmgUnit = (unitGuid.GetCounter() == playerGuid) ? 0 : (unitGuid.IsPlayer() ? unitGuid.GetCounter() : unitGuid.GetEntry()); log.SetCreature(unitGuid.IsCreatureOrPet()); log.damage = damage > 0 ? int16(damage) : -int16(heal); log.spell = spell; ((std::vector<PlayerLogDamage>*)(data[done ? PLAYER_LOG_DAMAGE_DONE : PLAYER_LOG_DAMAGE_GET]))->push_back(log); }
bool RoomContainer::LoadWorldMap() { if (fWorldMap != NULL) return true; _Unload(); GUI* gui = GUI::Get(); gui->Clear(); if (!gui->Load("GUIWMAP")) { return false; } gui->ShowWindow(0); Window* window = gui->GetWindow(0); if (window != NULL) { // TODO: Move this into GUI ? Control* control = window->GetControlByID(4); if (control != NULL) control->AssociateRoom(this); } fAreaOffset.x = fAreaOffset.y = 0; Core::Get()->EnteredArea(this, NULL); SetName("WORLDMAP"); GraphicsEngine::Get()->SetWindowCaption(Name()); fWorldMap = gResManager->GetWMAP(Name()); worldmap_entry entry = fWorldMap->WorldMapEntry(); fWorldMapBackground = gResManager->GetMOS(entry.background_mos); fWorldMapBitmap = fWorldMapBackground->Image(); for (uint32 i = 0; i < fWorldMap->CountAreaEntries(); i++) { AreaEntry& areaEntry = fWorldMap->AreaEntryAt(i); const Bitmap* iconFrame = areaEntry.Icon(); IE::point position = areaEntry.Position(); GFX::rect iconRect(int16(position.x - iconFrame->Frame().w / 2), int16(position.y - iconFrame->Frame().h / 2), iconFrame->Frame().w, iconFrame->Frame().h); GraphicsEngine::Get()->BlitBitmap(iconFrame, NULL, fWorldMapBitmap, &iconRect); } return true; }
static DB_INLINE void blend_color_func(rgb_color* target, const rgb_color other, uint8 amount) { const uint8 alphaMix = (uint8)( ((int16(other.alpha)-int16(255-target->alpha))*amount)/255 + (255-target->alpha) ); target->red = (uint8)( ((int16(other.red)-int16(target->red))*alphaMix)/255 + target->red ); target->green = (uint8)( ((int16(other.green)-int16(target->green))*alphaMix)/255 + target->green ); target->blue = (uint8)( ((int16(other.blue)-int16(target->blue))*alphaMix)/255 + target->blue ); target->alpha = (uint8)( ((int16(other.alpha)-int16(target->alpha))*amount)/255 + target->alpha ); }
void HexMapTest::SetZoom(float deltaZoom, int multiplier) { if (deltaZoom >= 1) deltaZoom = (deltaZoom-1)*multiplier+1; else deltaZoom = (deltaZoom-1)+1; if (multiplier != 1 && deltaZoom > float(multiplier)) deltaZoom = float(multiplier); if (multiplier != 1 && deltaZoom < 1.0f/multiplier) deltaZoom = 1.0f/multiplier; zoom = zoom_initial * deltaZoom; screenTranslationX = int16(screenTranslationX_initial*zoom/zoom_initial); screenTranslationY = int16(screenTranslationY_initial*zoom/zoom_initial); SetModelMatrix(); }
static void ReadJP2KImage( GenericImage<P>& img, jas_stream_t* jp2Stream, jas_image_t* jp2Image ) { int width = jas_image_cmptwidth( jp2Image, 0 ); int height = jas_image_cmptheight( jp2Image, 0 ); int numberOfChannels = jas_image_numcmpts( jp2Image ); jas_matrix_t* pixels = nullptr; try { pixels = jas_matrix_create( 1, width ); if ( pixels == nullptr ) throw Error( "Memory allocation error reading JPEG2000 image" ); // Allocate pixel data img.AllocateData( width, height, numberOfChannels, (jas_clrspc_fam( jas_image_clrspc( jp2Image ) ) == JAS_CLRSPC_FAM_GRAY) ? ColorSpace::Gray : ColorSpace::RGB ); for ( int c = 0; c < numberOfChannels; ++c ) { int n = jas_image_cmptprec( jp2Image, c ); bool s = jas_image_cmptsgnd( jp2Image, c ) != 0; for ( int y = 0; y < height; ++y ) { jas_image_readcmpt( jp2Image, c, 0, y, width, 1, pixels ); typename P::sample* f = img.ScanLine( y, c ); if ( n == 8 ) { if ( s ) for ( int x = 0; x < width; ++x ) *f++ = P::ToSample( int8( jas_matrix_get( pixels, 0, x ) ) ); else for ( int x = 0; x < width; ++x ) *f++ = P::ToSample( uint8( jas_matrix_get( pixels, 0, x ) ) ); } else { if ( s ) for ( int x = 0; x < width; ++x ) *f++ = P::ToSample( int16( jas_matrix_get( pixels, 0, x ) ) ); else for ( int x = 0; x < width; ++x ) *f++ = P::ToSample( uint16( jas_matrix_get( pixels, 0, x ) ) ); } } } jas_matrix_destroy( pixels ), pixels = nullptr; } catch ( ... ) { if ( pixels != nullptr ) jas_matrix_destroy( pixels ); throw; } }
std::string MySQLPreparedStatement::getQueryString(std::string const& sqlPattern) const { std::string queryString = sqlPattern; size_t pos = 0; for (uint32 i = 0; i < m_stmt->statement_data.size(); i++) { pos = queryString.find('?', pos); std::stringstream ss; switch (m_stmt->statement_data[i].type) { case TYPE_BOOL: ss << uint16(m_stmt->statement_data[i].data.boolean); break; case TYPE_UI8: ss << uint16(m_stmt->statement_data[i].data.ui8); // stringstream will append a character with that code instead of numeric representation break; case TYPE_UI16: ss << m_stmt->statement_data[i].data.ui16; break; case TYPE_UI32: ss << m_stmt->statement_data[i].data.ui32; break; case TYPE_I8: ss << int16(m_stmt->statement_data[i].data.i8); // stringstream will append a character with that code instead of numeric representation break; case TYPE_I16: ss << m_stmt->statement_data[i].data.i16; break; case TYPE_I32: ss << m_stmt->statement_data[i].data.i32; break; case TYPE_UI64: ss << m_stmt->statement_data[i].data.ui64; break; case TYPE_I64: ss << m_stmt->statement_data[i].data.i64; break; case TYPE_FLOAT: ss << m_stmt->statement_data[i].data.f; break; case TYPE_DOUBLE: ss << m_stmt->statement_data[i].data.d; break; case TYPE_STRING: ss << '\'' << m_stmt->statement_data[i].str << '\''; break; case TYPE_NULL: ss << "NULL"; break; } std::string replaceStr = ss.str(); queryString.replace(pos, 1, replaceStr); pos += replaceStr.length(); } return queryString; }
//play npc emote static bool HandleNpcPlayEmoteCommand(ChatHandler* handler, const char* args) { uint32 emote = atoi((char*)args); Creature* target = handler->getSelectedCreature(); if (!target) { handler->SendSysMessage(LANG_SELECT_CREATURE); handler->SetSentErrorMessage(true); return false; } if (target->GetTransport() && target->GetGUIDTransport()) { PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_TRANSPORT_EMOTE); stmt->setInt16(0, int16(emote)); stmt->setInt32(1, target->GetTransport()->GetEntry()); stmt->setInt32(2, target->GetGUIDTransport()); WorldDatabase.Execute(stmt); } target->SetUInt32Value(UNIT_NPC_EMOTESTATE, emote); return true; }
uint64 KaxInternalBlock::ReadInternalHead(IOCallback & input) { binary Buffer[5], *cursor = Buffer; uint64 Result = input.read(cursor, 4); if (Result != 4) return Result; // update internal values TrackNumber = *cursor++; if ((TrackNumber & 0x80) == 0) { // there is extra data if ((TrackNumber & 0x40) == 0) { // We don't support track numbers that large ! return Result; } Result += input.read(&Buffer[4], 1); TrackNumber = (TrackNumber & 0x3F) << 8; TrackNumber += *cursor++; } else { TrackNumber &= 0x7F; } big_int16 b16; b16.Eval(cursor); assert(ParentCluster != NULL); Timecode = ParentCluster->GetBlockGlobalTimecode(int16(b16)); bLocalTimecodeUsed = false; cursor += 2; return Result; }
void _GlReplicateAlgo::FillOffsets( int32 index, int32 size, int32 low, int32 high, GlCache1d* cache) { float mod; if (cache) { float v = 0.5; if (size > 1) v = ( (index * 2) / float((size - 1) * 2) ); v = cache->At(v); //printf("\tGlTile %ld: mod %f v %f\n", index, mod, v); mod = v; } else mod = 1 / float((index * 2) + 2); // Old style (when algo1d's had At() -- new style should work fine #if 0 GlAlgo1d* algo = Algo1dAt(_ALGO_INDEX); if (algo) { float v = 0.5f; if (size > 1) v = ( (index * 2) / float((size - 1) * 2) ); v = algo->At(v); //printf("\tGlTile %ld: mod %f v %f\n", index, mod, v); mod = v; } else mod = 1 / float((index * 2) + 2); #endif float half = (high - low) / 2.0f; for (int32 k = 0; k < 256; k++) { if (k < low || k > high) mOffset[k] = 0; else mOffset[k] = int16((k - low - half) * mod); } }
//-------------------------------------------------------------------------- size_t PcmWavAudioCodec::readData(int16* _data, size_t _maxFrames) { size_t offset = mDataStream->tellg(); if(offset >= mEndOffset) return false; size_t frames = (mEndOffset - offset) / mBytesPerSampleInFile / mSoundInfo.channels; if(frames > _maxFrames) frames = _maxFrames; if(frames == 0) return 0; size_t sizeInBytes = frames * mBytesPerSampleInFile * mSoundInfo.channels; mDataStream->read( (void*) _data, sizeInBytes); if(mBytesPerSampleInFile == 1) { // in-place conversion 8-bit -> 16-bit // (waveform data range for 8-bit is [0..255], // for 16-bit is [-32768..32767] int8* srcptr = (int8*) _data + sizeInBytes; int16* destptr = _data + sizeInBytes; while(destptr != _data) *(--destptr) = int16(*(--srcptr)) * 256 - 32768; } return frames; }
WMOAreaTableEntry const* GetWMOAreaTableEntryByTripple(int32 rootid, int32 adtid, int32 groupid) { auto i = sWMOAreaInfoByTripple.find(WMOAreaTableKey(int16(rootid), int8(adtid), groupid)); if (i != sWMOAreaInfoByTripple.end()) return i->second; return nullptr; }
inline TUString::TUString(TSysStr& str, bool loan, TLangId lang) : Lang(lang), Kind(loan ? isExtBstr : isBstr), RefCnt(int16(loan ? 2 : 1)), Bstr(str.operator BSTR()) { }
inline TUString::TUString(BSTR str, bool loan, TLangId lang) : Lang(lang), Kind(loan ? isExtBstr : isBstr), RefCnt(int16(loan ? 2 : 1)), Bstr(str) { }
uint8 CMagicProcess::ExecuteType2(int magicid, int tid, int data1, int data2, int data3) { Packet result(AG_MAGIC_ATTACK_RESULT, uint8(MAGIC_EFFECTING)); int damage = m_pSrcUser->GetDamage(tid, magicid);; uint8 bResult = 1; result << magicid << m_pSrcUser->m_iUserId << tid << data1; if (damage > 0){ CNpc* pNpc = nullptr ; // Pointer initialization! pNpc = g_pMain->m_arNpc.GetData(tid-NPC_BAND); if(pNpc == nullptr || pNpc->m_NpcState == NPC_DEAD || pNpc->m_iHP == 0) { bResult = 0; goto packet_send; } if (!pNpc->SetDamage(magicid, damage, m_pSrcUser->m_strUserID, m_pSrcUser->m_iUserId + USER_BAND)) { result << int16(bResult) << data3 << int16(0) << int16(0) << int16(0) << int16(damage == 0 ? -104 : 0); g_pMain->Send(&result); pNpc->SendExpToUserList(); // 경험치 분배!! pNpc->SendDead(); m_pSrcUser->SendAttackSuccess(tid, MAGIC_ATTACK_TARGET_DEAD, damage, pNpc->m_iHP); //m_pSrcUser->SendAttackSuccess(tid, ATTACK_TARGET_DEAD, damage, pNpc->m_iHP); return bResult; } else { // 공격 결과 전송 m_pSrcUser->SendAttackSuccess(tid, ATTACK_SUCCESS, damage, pNpc->m_iHP); } } // else // result = 0; packet_send: // this is a little redundant but leaving it in just in case order is intended // this should all be removed eventually anyway... result << int16(bResult) << data3 << int16(0) << int16(0) << int16(0) << int16(damage == 0 ? -104 : 0); g_pMain->Send(&result); return bResult; }
std::string MySQLPreparedStatement::getQueryString(const char *query) { std::string queryString = query; uint32 pos = 0; for (uint32 i = 0; i < m_stmt->statement_data.size(); i++) { pos = queryString.find("?", pos); std::stringstream replace; replace << '\''; switch (m_stmt->statement_data[i].type) { case TYPE_BOOL: replace << (m_stmt->statement_data[i].data.boolean ? '1' : '0'); break; case TYPE_UI8: replace << uint16(m_stmt->statement_data[i].data.ui8); // stringstream will append a character with that code instead of numeric representation break; case TYPE_UI16: replace << m_stmt->statement_data[i].data.ui16; break; case TYPE_UI32: replace << m_stmt->statement_data[i].data.ui32; break; case TYPE_I8: replace << int16(m_stmt->statement_data[i].data.i8); // stringstream will append a character with that code instead of numeric representation break; case TYPE_I16: replace << m_stmt->statement_data[i].data.i16; break; case TYPE_I32: replace << m_stmt->statement_data[i].data.i32; break; case TYPE_UI64: replace << m_stmt->statement_data[i].data.ui64; break; case TYPE_I64: replace << m_stmt->statement_data[i].data.i64; break; case TYPE_FLOAT: replace << m_stmt->statement_data[i].data.f; break; case TYPE_DOUBLE: replace << m_stmt->statement_data[i].data.d; break; case TYPE_STRING: replace << m_stmt->statement_data[i].str; break; } replace << '\''; queryString.replace(pos, 1, replace.str()); } return queryString; }
void Core::CheckDataTypeSizes() { CheckType(int8(), 8, "int8"); CheckType(uint8(), 8, "uint8"); CheckType(int16(), 16, "int16"); CheckType(uint16(), 16, "uint16"); CheckType(int32(), 32, "int32"); CheckType(uint32(), 32, "uint32"); }
t_freq_gen::t_freq_gen(vector<uint16> frequencies, int8 db_level) { assert(frequencies.size() > 0); assert(db_level <= 0); _frequencies = frequencies; // dB = 20 * log(amplitude / 32768) // 32767 is used below as +32768 does not fit in 16 bits _amplitude = int16(pow(10.0, db_level / 20.0) * 32767 / _frequencies.size()); }
/** * Draws the enemy image */ void MeleeEnemy::draw() { if (mDrawDirection == 1) { Iw2DSetImageTransform(IW_2D_IMAGE_TRANSFORM_FLIP_X); } CIwSVec2 screenCentre = CIwSVec2((int16)Iw2DGetSurfaceWidth() >> 1, (int16)Iw2DGetSurfaceHeight() >> 1); b2Transform t = mBody->GetTransform(); CIwSVec2 pos = screenCentre + (CIwSVec2(int16(t.p.x*8), -int16(t.p.y*8))); float normalRegionHeight = (52.0f/100.0f) * ((mHealth/mMaxHealth)*100.0f); float hurtRegionHeight = 52.0f - normalRegionHeight; CIwColour col; col.Set(255, 50, 50); Iw2DSetColour(col); Iw2DDrawImageRegion(mImg, pos - CIwSVec2((mFrameWidth/1.5)*mSpriteScale, ((52/2)*mSpriteScale)), CIwSVec2(mFrameWidth*1.5, hurtRegionHeight*mSpriteScale), CIwSVec2(mFrame, mVerFrame), CIwSVec2(mFrameWidth, hurtRegionHeight)); col.Set(255, 255, 255); Iw2DSetColour(col); Iw2DDrawImageRegion(mImg, pos - CIwSVec2((mFrameWidth/1.5)*mSpriteScale, (((52/2)*mSpriteScale))-hurtRegionHeight), CIwSVec2(mFrameWidth*1.5, normalRegionHeight*mSpriteScale), CIwSVec2(mFrame, hurtRegionHeight+mVerFrame), CIwSVec2(mFrameWidth, normalRegionHeight)); if(mFrameDelay <= 0) { mFrame += (mFrameWidth); if (mFrame > (mFrameCount*mFrameWidth)) { //setIdle(); mFrame = 0; if(punching) { setIdle(); mPunchTimer = 10.0f; } } mFrameDelay = 5; } mFrameDelay--; Iw2DSetImageTransform(IW_2D_IMAGE_TRANSFORM_NONE); }
static int16 InterpolateAngle(int16 Angle, GLfloat MixFrac, int16 AddlAngle) { if (MixFrac != 0 && AddlAngle != Angle) { int16 AngleDiff = NORMALIZE_ANGLE(AddlAngle - Angle); if (AngleDiff >= HALF_CIRCLE) { AngleDiff -= FULL_CIRCLE; } Angle += int16(MixFrac*AngleDiff); } return NORMALIZE_ANGLE(Angle); }
void SampleConverter::convert(int16 *dest, const float *source, int samplecount) { while (samplecount--) { register int32 sample = (int32) (*source++ * 32767.0f); if (sample > 32767) *dest++ = 32767; else if (sample < -32767) *dest++ = -32767; else *dest++ = int16(sample); } }
//----------------------------------------------------------------------------- void ExampleRender() { static const CIwSVec2 imageSize(g_Image->GetWidth() >> 3, g_Image->GetHeight() >> 3); static const CIwSVec2 halfImageSize = imageSize >> 1; const CIwSVec2 screenCentre = CIwSVec2((int16)Iw2DGetSurfaceWidth() >> 1, (int16)Iw2DGetSurfaceHeight() >> 1); const b2Transform t = g_body->GetTransform(); const CIwSVec2 pos = screenCentre + (CIwSVec2(int16(t.p.x*8), -int16(t.p.y*8))); const float angle = -t.q.GetAngle() * (180.0f/3.14159f); // reverse angle as our screen-Y coord is reversed CIwMat2D rot; rot.SetRot(iwangle(angle * 1024 / 90), CIwVec2(pos) << 3); Iw2DSetTransformMatrixSubPixel(rot); Iw2DDrawImage(g_Image, pos - halfImageSize, imageSize); // Iw2DSetTransformMatrix(CIwMat2D::g_Identity); Iw2DSurfaceShow(); }
bool Debugger_v2::cmd_sceneInfo(int argc, const char **argv) { DebugPrintf("Current scene: %d '%s'\n", _vm->_currentScene, _vm->_sceneList[_vm->_currentScene].filename1); DebugPrintf("\n"); DebugPrintf("Exit information:\n"); DebugPrintf("Exit1: leads to %d, position %dx%d\n", int16(_vm->_sceneExit1), _vm->_sceneEnterX1, _vm->_sceneEnterY1); DebugPrintf("Exit2: leads to %d, position %dx%d\n", int16(_vm->_sceneExit2), _vm->_sceneEnterX2, _vm->_sceneEnterY2); DebugPrintf("Exit3: leads to %d, position %dx%d\n", int16(_vm->_sceneExit3), _vm->_sceneEnterX3, _vm->_sceneEnterY3); DebugPrintf("Exit4: leads to %d, position %dx%d\n", int16(_vm->_sceneExit4), _vm->_sceneEnterX4, _vm->_sceneEnterY4); DebugPrintf("Special exit information:\n"); if (!_vm->_specialExitCount) { DebugPrintf("No special exits.\n"); } else { DebugPrintf("This scene has %d special exits.\n", _vm->_specialExitCount); for (int i = 0; i < _vm->_specialExitCount; ++i) { DebugPrintf("SpecialExit%d: facing %d, position (x1/y1/x2/y2): %d/%d/%d/%d\n", i, _vm->_specialExitTable[20 + i], _vm->_specialExitTable[0 + i], _vm->_specialExitTable[5 + i], _vm->_specialExitTable[10 + i], _vm->_specialExitTable[15 + i]); } } return true; }
int16 TransformMatrix::getScaleAndShift(scaleInt_t& outScale, double inScale, int maxShift) { // I guess this function could be optimized. double testNumber = inScale; int shift = 0; while ( fabs(testNumber) < (32767/2) && ( shift <= maxShift ) ) { testNumber *= 2; shift += 1; } outScale = int16(testNumber/2.0); return shift-1; }
/** * @brief Handles King candidacy recommendations by * leaders of top 10 clans. * * @param pUser The user sending the packet. * @param pkt The packet. */ void CKingSystem::CandidacyRecommend(CUser * pUser, Packet & pkt) { Packet result(WIZ_KING, uint8(KING_ELECTION)); std::string strUserID; pkt.SByte(); pkt >> strUserID; if (strUserID.empty() || strUserID.length() > MAX_ID_SIZE) return; result << uint8(KING_ELECTION_NOMINATE); // Make sure it's nomination time. if (m_byType != ELECTION_TYPE_NOMINATION) { result << int16(-2); pUser->Send(&result); return; } FastGuard lock(m_lock); // Make sure the user nominating a King is a clan leader if (!pUser->isClanLeader() // ... of a top 10 clan. || m_top10ClanSet.find(pUser->GetClanID()) == m_top10ClanSet.end() // ... and they haven't resigned their candidacy. || m_resignedCandidateList.find(pUser->m_strUserID) != m_resignedCandidateList.end()) { result << int16(-3); pUser->Send(&result); return; } // Send request to database. result << strUserID; g_pMain->AddDatabaseRequest(result, pUser); }