bool Load() { _decayRate = GetId() != SPELL_TIMER_BLAZING_SKELETON ? 1000 : 5000; return true; }
void wxTopLevelWindowGTK::GtkOnSize() { // avoid recursions if (m_resizing) return; m_resizing = true; if ( m_wxwindow == NULL ) return; /* wxMDIChildFrame derives from wxFrame but it _is_ a wxWindow as it uses wxWindow::Create to create it's GTK equivalent. m_mainWidget is only set in wxFrame::Create so it is used to check what kind of frame we have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we skip the part which handles m_frameMenuBar, m_frameToolBar and (most importantly) m_mainWidget */ int minWidth = GetMinWidth(), minHeight = GetMinHeight(), maxWidth = GetMaxWidth(), maxHeight = GetMaxHeight(); #ifdef __WXGPE__ // GPE's window manager doesn't like size hints // at all, esp. when the user has to use the // virtual keyboard. minWidth = -1; minHeight = -1; maxWidth = -1; maxHeight = -1; #endif if ((minWidth != -1) && (m_width < minWidth)) m_width = minWidth; if ((minHeight != -1) && (m_height < minHeight)) m_height = minHeight; if ((maxWidth != -1) && (m_width > maxWidth)) m_width = maxWidth; if ((maxHeight != -1) && (m_height > maxHeight)) m_height = maxHeight; if (m_mainWidget) { // m_mainWidget holds the menubar, the toolbar and the client area, // which is represented by m_wxwindow. int client_x = m_miniEdge; int client_y = m_miniEdge + m_miniTitle; int client_w = m_width - 2*m_miniEdge; int client_h = m_height - 2*m_miniEdge - m_miniTitle; if (client_w < 0) client_w = 0; if (client_h < 0) client_h = 0; // Let the parent perform the resize gtk_pizza_set_size( GTK_PIZZA(m_mainWidget), m_wxwindow, client_x, client_y, client_w, client_h ); } else { // If there is no m_mainWidget between m_widget and m_wxwindow there // is no need to set the size or position of m_wxwindow. } m_sizeSet = true; // send size event to frame wxSizeEvent event( wxSize(m_width,m_height), GetId() ); event.SetEventObject( this ); GetEventHandler()->ProcessEvent( event ); m_resizing = false; }
void ArenaTeam::Disband(WorldSession* session) { // Remove all members from arena team while (!Members.empty()) DelMember(Members.front().Guid, false); // Broadcast update if (session) { BroadcastEvent(ERR_ARENA_TEAM_DISBANDED_S, 0, 2, session->GetPlayerName(), GetName(), ""); if (Player *player = session->GetPlayer()) sLog->outArena("Player: %s [GUID: %u] disbanded arena team type: %u [Id: %u].", player->GetName(), player->GetGUIDLow(), GetType(), GetId()); } // Update database SQLTransaction trans = CharacterDatabase.BeginTransaction(); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ARENA_TEAM); stmt->setUInt32(0, TeamId); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ARENA_TEAM_MEMBERS); stmt->setUInt32(0, TeamId); trans->Append(stmt); CharacterDatabase.CommitTransaction(trans); // Remove arena team from ObjectMgr sArenaTeamMgr->RemoveArenaTeam(TeamId); }
/* - return the right instance for the object, based on its InstanceId - create the instance if it's not created already - the player is not actually added to the instance (only in InstanceMap::Add) */ Map* MapInstanced::CreateInstanceForPlayer(const uint32 mapId, Player* player) { if (GetId() != mapId || !player) return NULL; Map* map = NULL; uint32 newInstanceId = 0; // instanceId of the resulting map if (IsBattlegroundOrArena()) { // instantiate or find existing bg map for player // the instance id is set in battlegroundid newInstanceId = player->GetBattlegroundId(); if (!newInstanceId) return NULL; map = sMapMgr->FindMap(mapId, newInstanceId); if (!map) { if (Battleground* bg = player->GetBattleground()) map = CreateBattleground(newInstanceId, bg); else { player->TeleportToBGEntryPoint(); return NULL; } } } else { InstancePlayerBind* pBind = player->GetBoundInstance(GetId(), player->GetDifficulty(IsRaid())); InstanceSave* pSave = pBind ? pBind->save : NULL; // the player's permanent player bind is taken into consideration first // then the player's group bind and finally the solo bind. if (!pBind || !pBind->perm) { InstanceGroupBind* groupBind = NULL; Group* group = player->GetGroup(); // use the player's difficulty setting (it may not be the same as the group's) if (group) { groupBind = group->GetBoundInstance(this); if (groupBind) pSave = groupBind->save; } } if (pSave) { // solo/perm/group newInstanceId = pSave->GetInstanceId(); map = FindInstanceMap(newInstanceId); // it is possible that the save exists but the map doesn't if (!map) map = CreateInstance(newInstanceId, pSave, pSave->GetDifficulty()); } else { // if no instanceId via group members or instance saves is found // the instance will be created for the first time newInstanceId = sMapMgr->GenerateInstanceId(); Difficulty diff = player->GetGroup() ? player->GetGroup()->GetDifficulty(IsRaid()) : player->GetDifficulty(IsRaid()); //Seems it is now possible, but I do not know if it should be allowed //ASSERT(!FindInstanceMap(NewInstanceId)); map = FindInstanceMap(newInstanceId); if (!map) map = CreateInstance(newInstanceId, NULL, diff); } } return map; }
void CKinematics2DEngine::RemoveControllableEntity(const std::string& str_id) { TControllableEntityMap::iterator it = m_tControllableEntities.find(str_id); if(it != m_tControllableEntities.end()) { m_tControllableEntities.erase(it); } else { THROW_ARGOSEXCEPTION("Controllable entity id \"" << str_id << "\" not found in kinematics 2D engine \"" << GetId() << "\""); } }
uint8 ArenaTeam::GetSlot() const { uint8 slot = GetSlotByType(GetType()); if(slot >= MAX_ARENA_SLOT) { sLog.outError("Unknown arena team type %u for arena team %u", uint32(GetType()), GetId()); return 0; // better return existed slot to prevent untelated data curruption } return slot; }
void ArenaTeam::SetStats(uint32 stat_type, uint32 value) { switch(stat_type) { case STAT_TYPE_RATING: stats.rating = value; CharacterDatabase.PExecute("UPDATE arena_team_stats SET rating = '%u' WHERE arenateamid = '%u'", value, GetId()); break; case STAT_TYPE_GAMES_WEEK: stats.games_week = value; CharacterDatabase.PExecute("UPDATE arena_team_stats SET games = '%u' WHERE arenateamid = '%u'", value, GetId()); break; case STAT_TYPE_WINS_WEEK: stats.wins_week = value; CharacterDatabase.PExecute("UPDATE arena_team_stats SET wins = '%u' WHERE arenateamid = '%u'", value, GetId()); break; case STAT_TYPE_GAMES_SEASON: stats.games_season = value; CharacterDatabase.PExecute("UPDATE arena_team_stats SET played = '%u' WHERE arenateamid = '%u'", value, GetId()); break; case STAT_TYPE_WINS_SEASON: stats.wins_season = value; CharacterDatabase.PExecute("UPDATE arena_team_stats SET wins2 = '%u' WHERE arenateamid = '%u'", value, GetId()); break; case STAT_TYPE_RANK: stats.rank = value; CharacterDatabase.PExecute("UPDATE arena_team_stats SET rank = '%u' WHERE arenateamid = '%u'", value, GetId()); break; default: sLog.outDebug("unknown stat type in ArenaTeam::SetStats() %u", stat_type); break; } }
wxObject* wxsTextCtrl::OnBuildPreview(wxWindow* Parent,long Flags) { wxTextCtrl* Preview = new wxTextCtrl(Parent,GetId(),Text,Pos(Parent),Size(Parent),Style()); return SetupWindow(Preview,Flags); }
void FShaderResource::Register() { ShaderResourceIdMap.Add(GetId(), this); }
void dgWorldBase::CalculateJointForces(const dgBodyCluster& cluster, dgBodyInfo* const bodyArray, dgJointInfo* const jointArray, dgFloat32 timestep) { DG_TRACKTIME_NAMED(GetId()); dgSolver::CalculateJointForces(cluster, bodyArray, jointArray, timestep); }
bool ArenaTeam::Create(ObjectGuid captainGuid, uint8 type, std::string const& teamName, uint32 backgroundColor, uint8 emblemStyle, uint32 emblemColor, uint8 borderStyle, uint32 borderColor) { // Check if captain is present if (!ObjectAccessor::FindPlayer(captainGuid)) return false; // Check if arena team name is already taken if (sArenaTeamMgr->GetArenaTeamByName(teamName)) return false; // Generate new arena team id TeamId = sArenaTeamMgr->GenerateArenaTeamId(); // Assign member variables CaptainGuid = captainGuid; Type = type; TeamName = teamName; BackgroundColor = backgroundColor; EmblemStyle = emblemStyle; EmblemColor = emblemColor; BorderStyle = borderStyle; BorderColor = borderColor; uint32 captainLowGuid = captainGuid.GetCounter(); // Save arena team to db PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_TEAM); stmt->setUInt32(0, TeamId); stmt->setString(1, TeamName); stmt->setUInt32(2, captainLowGuid); stmt->setUInt8(3, Type); stmt->setUInt16(4, Stats.Rating); stmt->setUInt32(5, BackgroundColor); stmt->setUInt8(6, EmblemStyle); stmt->setUInt32(7, EmblemColor); stmt->setUInt8(8, BorderStyle); stmt->setUInt32(9, BorderColor); CharacterDatabase.Execute(stmt); // Add captain as member AddMember(CaptainGuid); TC_LOG_DEBUG("bg.arena", "New ArenaTeam created [Id: %u, Name: %s] [Type: %u] [Captain low GUID: %u]", GetId(), GetName().c_str(), GetType(), captainLowGuid); return true; }
FileEditor* GetById(int ID) { return GetId()==ID?this:nullptr; }
// // Return the id for calling Win32 API functions // int wxMenuItem::GetRealId() const { return m_subMenu ? (int)m_subMenu->GetHMenu() : GetId(); } // end of wxMenuItem::GetRealId
void wxHeaderCtrl::OnMouse(wxMouseEvent& mevent) { // do this in advance to allow simply returning if we're not interested, // we'll undo it if we do handle the event below mevent.Skip(); // account for the control displacement const int xPhysical = mevent.GetX(); const int xLogical = xPhysical - m_scrollOffset; // first deal with the [continuation of any] dragging operations in // progress if ( IsResizing() ) { if ( mevent.LeftUp() ) EndResizing(xPhysical); else // update the live separator position StartOrContinueResizing(m_colBeingResized, xPhysical); return; } if ( IsReordering() ) { if ( !mevent.LeftUp() ) { // update the column position UpdateReorderingMarker(xPhysical); return; } // finish reordering and continue to generate a click event below if we // didn't really reorder anything if ( EndReordering(xPhysical) ) return; } // find if the event is over a column at all bool onSeparator; const unsigned col = mevent.Leaving() ? (onSeparator = false, COL_NONE) : FindColumnAtPoint(xLogical, &onSeparator); // update the highlighted column if it changed if ( col != m_hover ) { const unsigned hoverOld = m_hover; m_hover = col; RefreshColIfNotNone(hoverOld); RefreshColIfNotNone(m_hover); } // update mouse cursor as it moves around if ( mevent.Moving() ) { SetCursor(onSeparator ? wxCursor(wxCURSOR_SIZEWE) : wxNullCursor); return; } // all the other events only make sense when they happen over a column if ( col == COL_NONE ) return; // enter various dragging modes on left mouse press if ( mevent.LeftDown() ) { if ( onSeparator ) { // start resizing the column wxASSERT_MSG( !IsResizing(), "reentering column resize mode?" ); StartOrContinueResizing(col, xPhysical); } else // on column itself { // start dragging the column wxASSERT_MSG( !IsReordering(), "reentering column move mode?" ); StartReordering(col, xPhysical); } return; } // determine the type of header event corresponding to click events wxEventType evtType = wxEVT_NULL; const bool click = mevent.ButtonUp(), dblclk = mevent.ButtonDClick(); if ( click || dblclk ) { switch ( mevent.GetButton() ) { case wxMOUSE_BTN_LEFT: // treat left double clicks on separator specially if ( onSeparator && dblclk ) { evtType = wxEVT_HEADER_SEPARATOR_DCLICK; } else // not double click on separator { evtType = click ? wxEVT_HEADER_CLICK : wxEVT_HEADER_DCLICK; } break; case wxMOUSE_BTN_RIGHT: evtType = click ? wxEVT_HEADER_RIGHT_CLICK : wxEVT_HEADER_RIGHT_DCLICK; break; case wxMOUSE_BTN_MIDDLE: evtType = click ? wxEVT_HEADER_MIDDLE_CLICK : wxEVT_HEADER_MIDDLE_DCLICK; break; default: // ignore clicks from other mouse buttons ; } } if ( evtType == wxEVT_NULL ) return; wxHeaderCtrlEvent event(evtType, GetId()); event.SetEventObject(this); event.SetColumn(col); if ( GetEventHandler()->ProcessEvent(event) ) mevent.Skip(false); }
bool wxHeaderCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) { NMHEADER * const nmhdr = (NMHEADER *)lParam; wxEventType evtType = wxEVT_NULL; int width = 0; int order = -1; bool veto = false; const UINT code = nmhdr->hdr.code; // we don't have the index for all events, e.g. not for NM_RELEASEDCAPTURE // so only access for header control events (and yes, the direction of // comparisons with FIRST/LAST is correct even if it seems inverted) int idx = code <= HDN_FIRST && code > HDN_LAST ? nmhdr->iItem : -1; if ( idx != -1 ) { // we also get bogus HDN_BEGINDRAG with -1 index so don't call // MSWFromNativeIdx() unconditionally for nmhdr->iItem idx = MSWFromNativeIdx(idx); } switch ( code ) { // click events // ------------ case HDN_ITEMCLICK: case HDN_ITEMDBLCLICK: evtType = GetClickEventType(code == HDN_ITEMDBLCLICK, nmhdr->iButton); break; // although we should get the notifications about the right clicks // via HDN_ITEM[DBL]CLICK too according to MSDN this simply doesn't // happen in practice on any Windows system up to 2003 case NM_RCLICK: case NM_RDBLCLK: { POINT pt; idx = wxMSWGetColumnClicked(&nmhdr->hdr, &pt); if ( idx != wxNOT_FOUND ) { idx = MSWFromNativeIdx(idx); // due to a bug in mingw32 headers NM_RDBLCLK is signed // there so we need a cast to avoid warnings about signed/ // unsigned comparison evtType = GetClickEventType( code == static_cast<UINT>(NM_RDBLCLK), 1); } //else: ignore clicks outside any column } break; case HDN_DIVIDERDBLCLICK: evtType = wxEVT_COMMAND_HEADER_SEPARATOR_DCLICK; break; // column resizing events // ---------------------- // see comments in wxListCtrl::MSWOnNotify() for why we catch both // ASCII and Unicode versions of this message case HDN_BEGINTRACKA: case HDN_BEGINTRACKW: // non-resizable columns can't be resized no matter what, don't // even generate any events for them if ( !GetColumn(idx).IsResizeable() ) { veto = true; break; } evtType = wxEVT_COMMAND_HEADER_BEGIN_RESIZE; // fall through case HDN_ENDTRACKA: case HDN_ENDTRACKW: width = nmhdr->pitem->cxy; if ( evtType == wxEVT_NULL ) { evtType = wxEVT_COMMAND_HEADER_END_RESIZE; // don't generate events with invalid width const int minWidth = GetColumn(idx).GetMinWidth(); if ( width < minWidth ) width = minWidth; } break; case HDN_ITEMCHANGING: if ( nmhdr->pitem && (nmhdr->pitem->mask & HDI_WIDTH) ) { // prevent the column from being shrunk beneath its min width width = nmhdr->pitem->cxy; if ( width < GetColumn(idx).GetMinWidth() ) { // don't generate any events and prevent the change from // happening veto = true; } else // width is acceptable { // generate the resizing event from here as we don't seem // to be getting HDN_TRACK events at all, at least with // comctl32.dll v6 evtType = wxEVT_COMMAND_HEADER_RESIZING; } } break; // column reordering events // ------------------------ case HDN_BEGINDRAG: // Windows sometimes sends us events with invalid column indices if ( nmhdr->iItem == -1 ) break; // column must have the appropriate flag to be draggable if ( !GetColumn(idx).IsReorderable() ) { veto = true; break; } evtType = wxEVT_COMMAND_HEADER_BEGIN_REORDER; break; case HDN_ENDDRAG: wxASSERT_MSG( nmhdr->pitem->mask & HDI_ORDER, "should have order" ); order = nmhdr->pitem->iOrder; // we also get messages with invalid order when column reordering // is cancelled (e.g. by pressing Esc) if ( order == -1 ) break; order = MSWFromNativeOrder(order); evtType = wxEVT_COMMAND_HEADER_END_REORDER; break; case NM_RELEASEDCAPTURE: evtType = wxEVT_COMMAND_HEADER_DRAGGING_CANCELLED; break; } // do generate the corresponding wx event if ( evtType != wxEVT_NULL ) { wxHeaderCtrlEvent event(evtType, GetId()); event.SetEventObject(this); event.SetColumn(idx); event.SetWidth(width); if ( order != -1 ) event.SetNewOrder(order); const bool processed = GetEventHandler()->ProcessEvent(event); if ( processed && !event.IsAllowed() ) veto = true; if ( !veto ) { // special post-processing for HDN_ENDDRAG: we need to update the // internal column indices array if this is allowed to go ahead as // the native control is going to reorder its columns now if ( evtType == wxEVT_COMMAND_HEADER_END_REORDER ) MoveColumnInOrderArray(m_colIndices, idx, order); if ( processed ) { // skip default processing below return true; } } } if ( veto ) { // all of HDN_BEGIN{DRAG,TRACK}, HDN_TRACK and HDN_ITEMCHANGING // interpret TRUE return value as meaning to stop the control // default handling of the message *result = TRUE; return true; } return wxHeaderCtrlBase::MSWOnNotify(idCtrl, lParam, result); }
void FShader::Deregister() { Type->GetShaderIdMap().Remove(GetId()); }
bool wxComboBox::MSWCommand(WXUINT param, WXWORD id) { int sel = -1; wxString value; switch ( param ) { case CBN_DROPDOWN: // remember the last selection, just as wxChoice does m_lastAcceptedSelection = GetCurrentSelection(); { wxCommandEvent event(wxEVT_COMBOBOX_DROPDOWN, GetId()); event.SetEventObject(this); ProcessCommand(event); } break; case CBN_CLOSEUP: // Do the same thing as in wxChoice but using different event type. if ( m_pendingSelection != wxID_NONE ) { SendSelectionChangedEvent(wxEVT_COMBOBOX); m_pendingSelection = wxID_NONE; } { wxCommandEvent event(wxEVT_COMBOBOX_CLOSEUP, GetId()); event.SetEventObject(this); ProcessCommand(event); } break; case CBN_SELENDOK: #ifndef __SMARTPHONE__ // we need to reset this to prevent the selection from being undone // by wxChoice, see wxChoice::MSWCommand() and comments there m_lastAcceptedSelection = wxID_NONE; #endif // set these variables so that they could be also fixed in // CBN_EDITCHANGE below sel = GetSelection(); value = GetStringSelection(); // this string is going to become the new combobox value soon but // we need it to be done right now, otherwise the event handler // could get a wrong value when it calls our GetValue() ::SetWindowText(GetHwnd(), value.t_str()); SendSelectionChangedEvent(wxEVT_COMBOBOX); // fall through: for compatibility with wxGTK, also send the text // update event when the selection changes (this also seems more // logical as the text does change) case CBN_EDITCHANGE: if ( m_allowTextEvents ) { wxCommandEvent event(wxEVT_TEXT, GetId()); // if sel != -1, value was already initialized above if ( sel == -1 ) { value = wxGetWindowText(GetHwnd()); } event.SetString(value); InitCommandEventWithItems(event, sel); ProcessCommand(event); } break; default: return wxChoice::MSWCommand(param, id); } // skip wxChoice version as it would generate its own events for // CBN_SELENDOK and also interfere with our handling of CBN_DROPDOWN return true; }
void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe ) { wxString sep = wxFileName().GetPathSeparator(); wxString fullFileName = GetFileName(); wxTreeItemId id = GetId(); KICAD_MANAGER_FRAME* frame = (KICAD_MANAGER_FRAME*) Pgm().App().GetTopWindow(); switch( GetType() ) { case TREE_PROJECT: break; case TREE_DIRECTORY: m_parent->Toggle( id ); break; case TREE_SCHEMA: if( fullFileName == frame->SchFileName() ) { // the project's schematic is opened using the *.kiface as part of this process. frame->RunEeschema( fullFileName ); } else { // schematics not part of the project are opened in a separate process. frame->Execute( m_parent, EESCHEMA_EXE, fullFileName ); } break; case TREE_LEGACY_PCB: case TREE_SEXP_PCB: if( fullFileName == frame->PcbFileName() || fullFileName == frame->PcbLegacyFileName() ) { // the project's BOARD is opened using the *.kiface as part of this process. frame->RunPcbNew( fullFileName ); } else { // boards not part of the project are opened in a separate process. frame->Execute( m_parent, PCBNEW_EXE, fullFileName ); } break; case TREE_GERBER: frame->Execute( m_parent, GERBVIEW_EXE, fullFileName ); break; case TREE_PDF: AddDelimiterString( fullFileName ); OpenPDF( fullFileName ); break; case TREE_NET: frame->Execute( m_parent, CVPCB_EXE, fullFileName ); break; case TREE_TXT: { wxString editorname = Pgm().GetEditorName(); if( !editorname.IsEmpty() ) frame->Execute( m_parent, editorname, fullFileName ); } break; case TREE_PAGE_LAYOUT_DESCR: frame->Execute( m_parent, PL_EDITOR_EXE, fullFileName ); break; default: AddDelimiterString( fullFileName ); OpenFile( fullFileName ); break; } }
void ArenaTeam::DelMember(uint64 guid) { for (MemberList::iterator itr = members.begin(); itr != members.end(); ++itr) { if (itr->guid == guid) { members.erase(itr); break; } } Player *player = objmgr.GetPlayer(guid); if(player) { player->SetInArenaTeam(0, GetSlot()); player->GetSession()->SendArenaTeamCommandResult(ERR_ARENA_TEAM_QUIT_S, GetName(), "", 0); // delete all info regarding this team for(int i = 0; i < 6; ++i) { player->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * 6) + i, 0); } } CharacterDatabase.PExecute("DELETE FROM arena_team_member WHERE arenateamid = '%u' AND guid = '%u'", GetId(), GUID_LOPART(guid)); }
void ArenaTeam::DelMember(ObjectGuid guid) { for (MemberList::iterator itr = m_members.begin(); itr != m_members.end(); ++itr) { if (itr->guid == guid) { m_members.erase(itr); break; } } if(Player *player = sObjectMgr.GetPlayer(guid)) { player->GetSession()->SendArenaTeamCommandResult(ERR_ARENA_TEAM_QUIT_S, GetName(), "", 0); // delete all info regarding this team for(int i = 0; i < ARENA_TEAM_END; ++i) player->SetArenaTeamInfoField(GetSlot(), ArenaTeamInfoType(i), 0); } CharacterDatabase.PExecute("DELETE FROM arena_team_member WHERE arenateamid = '%u' AND guid = '%u'", GetId(), guid.GetCounter()); }
void ArenaTeam::SaveToDB() { // save team and member stats to db // called after a match has ended, or when calculating arena_points CharacterDatabase.PExecute("UPDATE arena_team_stats SET rating = '%u',games = '%u',played = '%u',rank = '%u',wins = '%u',wins2 = '%u' WHERE arenateamid = '%u'", stats.rating, stats.games_week, stats.games_season, stats.rank, stats.wins_week, stats.wins_season, GetId()); for(MemberList::iterator itr = members.begin(); itr != members.end(); ++itr) { CharacterDatabase.PExecute("UPDATE arena_team_member SET played_week = '%u', wons_week = '%u', played_season = '%u', wons_season = '%u', personal_rating = '%u' WHERE arenateamid = '%u' AND guid = '%u'", itr->games_week, itr->wins_week, itr->games_season, itr->wins_season, itr->personal_rating, Id, itr->guid); } }
static int ScanOneLine(unsigned char *line) { char *q,*p = strchr(line,')'); DataPoint d; const DataPoint *old=NULL; size_t typ=0; int t; if (p == NULL) return -1; q = p+1; *p-- = 0; while (*p == ' ' ) p--; while (isId(p)) { p--; } p++; while (*q == ' ') q++; if (*q == '(') q++; else return -1; if (Data == NULL) { Data = iDictionary.Create(sizeof(DataPoint),200); } old = iDictionary.GetElement(Data,p); memset(&d,0,sizeof(d)); t = istrCollection.IndexOf(Exceptions,p,&typ); //printf("%s: t=%d, index %ull\n",p,t,typ); if (t >= 0) { char *save = p; p = line; while (*p == ' ' || *p == '\t') p++; q = GetId(p); *q = 0; t = FindType(p); if (t < 0) { if (strcmp(p,"ElementType")) { return -1; } typ = 3; } else typ = t; if (old == NULL) d.ApiName = strdup(save); } else { if (old ==NULL) d.ApiName = strdup(p); p = q; q = GetId(q); *q=0; if (!strcmp(p,"const")) { q++; while (*q == ' ' || *q == '\t') q++; p = q; q = GetId(q); *q=0; } t = FindType(p); if (t < 0) { if (strcmp(p,"ElementType")) { free(d.ApiName); return -1; } typ = 12; } else typ = t; } if (old) { memcpy(&d,old,sizeof(DataPoint)); } d.type[typ] = typ+1; if (Data == NULL) { Data = iDictionary.Create(sizeof(DataPoint),200); } iDictionary.Add(Data,d.ApiName,&d); return 1; }
void CKinematics2DEngine::RemovePhysicsEntity(const std::string& str_id) { TKinematics2DEntityMap::iterator it = m_tPhysicsEntities.find(str_id); if(it != m_tPhysicsEntities.end()) { delete it->second; m_tPhysicsEntities.erase(it); } else { THROW_ARGOSEXCEPTION("entity id \"" << str_id << "\" not found in kinematics 2D engine \"" << GetId() << "\""); } }
bool ArenaTeam::LoadMembersFromDB(QueryResult result) { if (!result) return false; bool captainPresentInTeam = false; do { Field* fields = result->Fetch(); // Prevent crash if db records are broken when all members in result are already processed and current team doesn't have any members if (!fields) break; uint32 arenaTeamId = fields[0].GetUInt32(); // We loaded all members for this arena_team already, break cycle if (arenaTeamId > TeamId) break; ArenaTeamMember newMember; newMember.Guid = MAKE_NEW_GUID(fields[1].GetUInt32(), 0, HIGHGUID_PLAYER); newMember.WeekGames = fields[2].GetUInt16(); newMember.WeekWins = fields[3].GetUInt16(); newMember.SeasonGames = fields[4].GetUInt16(); newMember.SeasonWins = fields[5].GetUInt16(); //newMember.Name = fields[6].GetString(); newMember.Class = fields[7].GetUInt8(); newMember.PersonalRating = fields[8].GetUInt16(); newMember.MatchMakerRating = fields[9].GetUInt16() > 0 ? fields[9].GetUInt16() : sWorld->getIntConfig(CONFIG_ARENA_START_MATCHMAKER_RATING);; newMember.MaxMMR = std::max(fields[10].GetUInt16(), newMember.MatchMakerRating); // Delete member if character information is missing if (fields[6].GetString().empty()) { sLog->outErrorDb("ArenaTeam %u has member with empty name - probably player %u doesn't exist, deleting him from memberlist!", arenaTeamId, GUID_LOPART(newMember.Guid)); this->DelMember(newMember.Guid, true); continue; } // Check if team team has a valid captain if (newMember.Guid == GetCaptain()) captainPresentInTeam = true; // Put the player in the team Members.push_back(newMember); sWorld->UpdateGlobalPlayerArenaTeam(GUID_LOPART(newMember.Guid), GetSlot(), GetId()); } while (result->NextRow()); if (Empty() || !captainPresentInTeam) { // Arena team is empty or captain is not in team, delete from db #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_BATTLEGROUND, "ArenaTeam %u does not have any members or its captain is not in team, disbanding it...", TeamId); #endif return false; } return true; }
bool wxComboBox::MSWCommand(WXUINT param, WXWORD WXUNUSED(id)) { wxString value; int sel = -1; switch ( param ) { case CBN_SELENDOK: case CBN_SELCHANGE: sel = GetSelection(); // we may sometimes get 2 CBN_SELCHANGE events or a CBN_SELENDOK // before CBN_SELCHANGE with the same index when the user selects // an item in the combobox -- ignore duplicates if ( sel > -1 && sel != m_selectionOld ) { m_selectionOld = sel; // GetValue() would still return the old value from here but // according to the docs we should return the new value if the // user calls it in his event handler, so update internal // m_value m_value = GetString(sel); wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_SELECTED, GetId()); event.SetInt(sel); event.SetEventObject(this); event.SetString(m_value); ProcessCommand(event); } else // no valid selection { m_selectionOld = sel; // hence no EVT_TEXT neither break; } // fall through: for compability with wxGTK, also send the text // update event when the selection changes (this also seems more // logical as the text does change) case CBN_EDITCHANGE: { wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, GetId()); // if sel != -1, value was initialized above (and we can't use // GetValue() here as it would return the old selection and we // want the new one) if ( sel == -1 ) { m_value = wxGetWindowText(GetHwnd()); m_selectionOld = -1; } else // we're synthesizing text updated event from sel change { // We need to retrieve the current selection because the // user may have changed it in the previous handler (for // CBN_SELCHANGE above). sel = GetSelection(); if ( sel > -1 ) { m_value = GetString(sel); } } event.SetString(m_value); event.SetEventObject(this); ProcessCommand(event); } break; } // there is no return value for the CBN_ notifications, so always return // false from here to pass the message to DefWindowProc() return false; }
bool ArenaTeam::AddMember(uint64 playerGuid) { std::string playerName; uint8 playerClass; // Check if arena team is full (Can't have more than type * 2 players) if (GetMembersSize() >= GetType() * 2) return false; // xinef: Get player name and class from player storage or global data storage Player* player = ObjectAccessor::FindPlayerInOrOutOfWorld(playerGuid); if (player) { playerClass = player->getClass(); playerName = player->GetName(); } else { GlobalPlayerData const* playerData = sWorld->GetGlobalPlayerData(GUID_LOPART(playerGuid)); if (!playerData) return false; playerName = playerData->name; playerClass = playerData->playerClass; } // Check if player is already in a similar arena team if ((player && player->GetArenaTeamId(GetSlot())) || Player::GetArenaTeamIdFromStorage(GUID_LOPART(playerGuid), GetSlot()) != 0) { sLog->outError("Arena: Player %s (guid: %u) already has an arena team of type %u", playerName.c_str(), GUID_LOPART(playerGuid), GetType()); return false; } // Set player's personal rating uint32 personalRating = 0; if (sWorld->getIntConfig(CONFIG_ARENA_START_PERSONAL_RATING) > 0) personalRating = sWorld->getIntConfig(CONFIG_ARENA_START_PERSONAL_RATING); else if (GetRating() >= 1000) personalRating = 1000; // xinef: zomg! sync query // Try to get player's match maker rating from db and fall back to config setting if not found PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MATCH_MAKER_RATING); stmt->setUInt32(0, GUID_LOPART(playerGuid)); stmt->setUInt8(1, GetSlot()); PreparedQueryResult result = CharacterDatabase.Query(stmt); uint16 matchMakerRating; uint16 maxMMR; if (result) { matchMakerRating = (*result)[0].GetUInt16(); uint16 Max = (*result)[1].GetUInt16(); maxMMR = std::max(Max, matchMakerRating); } else { matchMakerRating = sWorld->getIntConfig(CONFIG_ARENA_START_MATCHMAKER_RATING); maxMMR = matchMakerRating; } // Remove all player signatures from other petitions // This will prevent player from joining too many arena teams and corrupt arena team data integrity Player::RemovePetitionsAndSigns(playerGuid, GetType()); // Feed data to the struct ArenaTeamMember newMember; //newMember.Name = playerName; newMember.Guid = playerGuid; newMember.Class = playerClass; newMember.SeasonGames = 0; newMember.WeekGames = 0; newMember.SeasonWins = 0; newMember.WeekWins = 0; newMember.PersonalRating = personalRating; newMember.MatchMakerRating = matchMakerRating; newMember.MaxMMR = maxMMR; Members.push_back(newMember); sWorld->UpdateGlobalPlayerArenaTeam(GUID_LOPART(playerGuid), GetSlot(), GetId()); // Save player's arena team membership to db stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_TEAM_MEMBER); stmt->setUInt32(0, TeamId); stmt->setUInt32(1, GUID_LOPART(playerGuid)); CharacterDatabase.Execute(stmt); // Inform player if online if (player) { player->SetInArenaTeam(TeamId, GetSlot(), GetType()); player->SetArenaTeamIdInvited(0); // Hide promote/remove buttons if (CaptainGuid != playerGuid) player->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_MEMBER, 1); } return true; }
void wxRibbonPanel::OnMouseClick(wxMouseEvent& WXUNUSED(evt)) { if(IsMinimised()) { if(m_expanded_panel != NULL) { HideExpanded(); } else { ShowExpanded(); } } else if(IsExtButtonHovered()) { wxRibbonPanelEvent notification(wxEVT_COMMAND_RIBBONPANEL_EXTBUTTON_ACTIVATED, GetId()); notification.SetEventObject(this); notification.SetPanel(this); ProcessEvent(notification); } }
bool ArenaTeam::AddMember(uint64 playerGuid) { std::string playerName; uint8 playerClass; // Check if arena team is full (Can't have more than type * 2 players) if (GetMembersSize() >= GetType() * 2) return false; // Get player name and class either from db or ObjectMgr Player* player = ObjectAccessor::FindPlayer(playerGuid); if (player) { playerClass = player->getClass(); playerName = player->GetName(); } else { // 0 1 // SELECT name, class FROM characters WHERE guid = ? PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_NAME_CLASS); stmt->setUInt32(0, GUID_LOPART(playerGuid)); PreparedQueryResult result = CharacterDatabase.Query(stmt); if (!result) return false; playerName = (*result)[0].GetString(); playerClass = (*result)[1].GetUInt8(); } // Check if player is already in a similar arena team if ((player && player->GetArenaTeamId(GetSlot())) || Player::GetArenaTeamIdFromDB(playerGuid, GetType()) != 0) { SF_LOG_DEBUG("bg.arena", "Arena: Player %s (guid: %u) already has an arena team of type %u", playerName.c_str(), GUID_LOPART(playerGuid), GetType()); return false; } // Set player's personal rating uint32 personalRating = 0; if (sWorld->getIntConfig(CONFIG_ARENA_START_PERSONAL_RATING) > 0) personalRating = sWorld->getIntConfig(CONFIG_ARENA_START_PERSONAL_RATING); else if (GetRating() >= 1000) personalRating = 1000; // Try to get player's match maker rating from db and fall back to config setting if not found PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MATCH_MAKER_RATING); stmt->setUInt32(0, GUID_LOPART(playerGuid)); stmt->setUInt8(1, GetSlot()); PreparedQueryResult result = CharacterDatabase.Query(stmt); uint32 matchMakerRating; if (result) matchMakerRating = (*result)[0].GetUInt16(); else matchMakerRating = sWorld->getIntConfig(CONFIG_ARENA_START_MATCHMAKER_RATING); // Remove all player signatures from other petitions // This will prevent player from joining too many arena teams and corrupt arena team data integrity Player::RemovePetitionsAndSigns(playerGuid, GetType()); // Feed data to the struct ArenaTeamMember newMember; newMember.Name = playerName; newMember.Guid = playerGuid; newMember.Class = playerClass; newMember.SeasonGames = 0; newMember.WeekGames = 0; newMember.SeasonWins = 0; newMember.WeekWins = 0; newMember.PersonalRating = personalRating; newMember.MatchMakerRating = matchMakerRating; Members.push_back(newMember); // Save player's arena team membership to db stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_TEAM_MEMBER); stmt->setUInt32(0, TeamId); stmt->setUInt32(1, GUID_LOPART(playerGuid)); CharacterDatabase.Execute(stmt); // Inform player if online if (player) { player->SetInArenaTeam(TeamId, GetSlot(), GetType()); player->SetArenaTeamIdInvited(0); // Hide promote/remove buttons if (CaptainGuid != playerGuid) player->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_MEMBER, 1); } SF_LOG_DEBUG("bg.arena", "Player: %s [GUID: %u] joined arena team type: %u [Id: %u, Name: %s].", playerName.c_str(), GUID_LOPART(playerGuid), GetType(), GetId(), GetName().c_str()); return true; }
bool ArenaTeam::Create(uint32 captainGuid, uint8 type, std::string teamName, uint32 backgroundColor, uint8 emblemStyle, uint32 emblemColor, uint8 borderStyle, uint32 borderColor) { // Check if captain is present if (!sObjectMgr->GetPlayer(captainGuid)) return false; // Check if arena team name is already taken if (sArenaTeamMgr->GetArenaTeamByName(TeamName)) return false; // Generate new arena team id TeamId = sArenaTeamMgr->GenerateArenaTeamId(); // Assign member variables CaptainGuid = captainGuid; Type = type; TeamName = teamName; BackgroundColor = backgroundColor; EmblemStyle = emblemStyle; EmblemColor = emblemColor; BorderStyle = borderStyle; BorderColor = borderColor; // Save arena team to db PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_ADD_ARENA_TEAM); stmt->setUInt32(0, TeamId); stmt->setString(1, TeamName); stmt->setUInt32(2, GUID_LOPART(CaptainGuid)); stmt->setUInt8(3, Type); stmt->setUInt16(4, Stats.Rating); stmt->setUInt32(5, BackgroundColor); stmt->setUInt8(6, EmblemStyle); stmt->setUInt32(7, EmblemColor); stmt->setUInt8(8, BorderStyle); stmt->setUInt32(9, BorderColor); CharacterDatabase.Execute(stmt); // Add captain as member AddMember(CaptainGuid); sLog->outArena("New ArenaTeam created [Id: %u] [Type: %u] [Captain low GUID: %u]", GetId(), GetType(), GUID_LOPART(CaptainGuid)); return true; }
void wxWindowDFB::PaintWindow(const wxRect& rect) { wxCHECK_RET( !IsFrozen() && IsShown(), "shouldn't be called" ); wxLogTrace(TRACE_PAINT, "%p ('%s'): painting region [%i,%i,%i,%i]", this, GetName().c_str(), rect.x, rect.y, rect.GetRight(), rect.GetBottom()); m_updateRegion = rect; // FIXME_DFB: don't waste time rendering the area if it's fully covered // by some children, go directly to rendering the children // (unless some child has HasTransparentBackground()=true!) // NB: unconditionally send wxEraseEvent, because our implementation of // wxWindow::Refresh() ignores the eraseBack argument wxWindowDC dc((wxWindow*)this); wxEraseEvent eventEr(m_windowId, &dc); eventEr.SetEventObject(this); HandleWindowEvent(eventEr); wxRect clientRect(GetClientRect()); // only send wxNcPaintEvent if drawing at least part of nonclient area: if ( !clientRect.Contains(rect) ) { wxNcPaintEvent eventNc(GetId()); eventNc.SetEventObject(this); HandleWindowEvent(eventNc); } else { wxLogTrace(TRACE_PAINT, "%p ('%s'): not sending wxNcPaintEvent", this, GetName().c_str()); } // only send wxPaintEvent if drawing at least part of client area: if ( rect.Intersects(clientRect) ) { wxPaintEvent eventPt(GetId()); eventPt.SetEventObject(this); HandleWindowEvent(eventPt); } else { wxLogTrace(TRACE_PAINT, "%p ('%s'): not sending wxPaintEvent", this, GetName().c_str()); } // draw window's overlays on top of the painted window, if we have any: PaintOverlays(rect); m_updateRegion.Clear(); // client area portion of 'rect': wxRect rectClientOnly(rect); rectClientOnly.Intersect(clientRect); // paint the children: wxPoint origin = GetClientAreaOrigin(); wxWindowList& children = GetChildren(); for ( wxWindowList::iterator i = children.begin(); i != children.end(); ++i ) { wxWindow *child = *i; if ( child->IsFrozen() || !child->IsShown() ) continue; // don't paint anything if the window is frozen or hidden // compute child's area to repaint wxRect childrect(child->GetRect()); childrect.Offset(origin); if ( child->CanBeOutsideClientArea() ) childrect.Intersect(rect); else childrect.Intersect(rectClientOnly); if ( childrect.IsEmpty() ) continue; // and repaint it: childrect.Offset(-child->GetPosition()); childrect.Offset(-origin); child->PaintWindow(childrect); } }