void CChat::Broadcast(CChatChanMember *pFrom, LPCTSTR pszText, CLanguageID lang, bool fOverride) { ADDTOCALLSTACK("CChat::Broadcast"); ClientIterator it; for (CClient *pClient = it.next(); pClient != NULL; pClient = it.next()) { if (!pClient->IsChatActive()) continue; if (fOverride || pClient->IsReceivingAllowed()) { CGString sName; DecorateName(sName, pFrom, fOverride); pClient->SendChatMsg(CHATMSG_PlayerTalk, sName, pszText, lang); } } }
bool CChat::CreateChannel(LPCTSTR pszName, LPCTSTR pszPassword, CChatChanMember * pMember) { ADDTOCALLSTACK("CChat::CreateChannel"); if (!m_fChatsOK) { CGString sName; DecorateName(sName, NULL, true); pMember->SendChatMsg(CHATMSG_PlayerTalk, sName, "Conference creation is disabled."); return false; } CChatChannel * pChannel = new CChatChannel( pszName, pszPassword ); m_Channels.InsertTail( pChannel ); pChannel->SetModerator(pMember->GetChatName()); // Send all clients with an open chat window the new channel name SendNewChannel(pChannel); return true; }
void CChat::WhereIs(CChatChanMember * pBy, LPCTSTR pszName ) const { ADDTOCALLSTACK("CChat::WhereIs"); ClientIterator it; for (CClient* pClient = it.next(); pClient != NULL; pClient = it.next()) { if ( ! strcmp( pClient->GetChatName(), pszName)) continue; TCHAR *pszMsg = Str_GetTemp(); if (! pClient->IsChatActive() || !pClient->GetChannel()) sprintf(pszMsg, "%s is not currently in a conference.", pszName); else sprintf(pszMsg, "%s is in conference '%s'.", static_cast<LPCTSTR>(pszName), static_cast<LPCTSTR>(pClient->GetChannel()->GetName())); CGString sFrom; DecorateName(sFrom, NULL, true); pBy->SendChatMsg(CHATMSG_PlayerTalk, sFrom, pszMsg); return; } pBy->SendChatMsg(CHATMSG_NoPlayer, pszName); }
void CChat::WhereIs(CChatChanMember * pBy, lpctstr pszName ) const { ADDTOCALLSTACK("CChat::WhereIs"); ClientIterator it; for (CClient* pClient = it.next(); pClient != nullptr; pClient = it.next()) { if ( ! strcmp( pClient->GetChatName(), pszName)) continue; tchar *pszMsg = Str_GetTemp(); if (! pClient->IsChatActive() || !pClient->GetChannel()) sprintf(pszMsg, "%s is not currently in a conference.", pszName); else sprintf(pszMsg, "%s is in conference '%s'.", pszName, pClient->GetChannel()->GetName()); CSString sFrom; DecorateName(sFrom, nullptr, true); pBy->SendChatMsg(CHATMSG_PlayerTalk, sFrom, pszMsg); return; } pBy->SendChatMsg(CHATMSG_NoPlayer, pszName); }
void CChat::DoCommand(CChatChanMember * pBy, LPCTSTR szMsg) { ADDTOCALLSTACK("CChat::DoCommand"); static LPCTSTR const sm_szCmd_Chat[] = { "ALLKICK", "BC", "BCALL", "CHATSOK", "CLEARIGNORE", "KILLCHATS", "NOCHATS", "SYSMSG", "WHEREIS" }; ASSERT(pBy != NULL); ASSERT(szMsg != NULL); TCHAR buffer[2048]; ASSERT(strlen(szMsg) < COUNTOF(buffer)); strcpy(buffer, szMsg); TCHAR * pszCommand = buffer; TCHAR * pszText = NULL; size_t iCommandLength = strlen(pszCommand); for (size_t i = 0; i < iCommandLength; i++) { ASSERT( i<COUNTOF(buffer)); if (pszCommand[i] == ' ') { pszCommand[i] = 0; pszText = pszCommand + i + 1; } } CGString sFrom; CChatChannel * pChannel = pBy->GetChannel(); CClient * pByClient = pBy->GetClient(); ASSERT(pByClient != NULL); switch ( FindTableSorted( pszCommand, sm_szCmd_Chat, COUNTOF(sm_szCmd_Chat))) { case 0: // "ALLKICK" { if (pChannel == NULL) { pBy->SendChatMsg(CHATMSG_MustBeInAConference); return; } if (!pChannel->IsModerator(pBy->GetChatName())) { pBy->SendChatMsg(CHATMSG_MustHaveOps); return; } pChannel->KickAll(pBy); DecorateName(sFrom, NULL, true); pBy->SendChatMsg(CHATMSG_PlayerTalk, sFrom, "All members have been kicked!", ""); return; } case 1: // "BC" { if ( ! pByClient->IsPriv( PRIV_GM )) { need_gm_privs: DecorateName(sFrom, NULL, true); pBy->SendChatMsg(CHATMSG_PlayerTalk, sFrom, "You need to have GM privs to use this command."); return; } Broadcast(pBy, pszText); return; } case 2: // "BCALL" { if ( ! pByClient->IsPriv( PRIV_GM )) goto need_gm_privs; Broadcast(pBy, pszText, "", true); return; } case 3: // "CHATSOK" { if ( ! pByClient->IsPriv( PRIV_GM )) goto need_gm_privs; if (!m_fChatsOK) { m_fChatsOK = true; Broadcast(NULL, "Conference creation is enabled."); } return; } case 4: // "CLEARIGNORE" { pBy->ClearIgnoreList(); return; } case 5: // "KILLCHATS" { if ( ! pByClient->IsPriv( PRIV_GM )) goto need_gm_privs; KillChannels(); return; } case 6: // "NOCHATS" { if ( ! pByClient->IsPriv( PRIV_GM )) goto need_gm_privs; if (m_fChatsOK) { Broadcast(NULL, "Conference creation is now disabled."); m_fChatsOK = false; } return; } case 7: // "SYSMSG" { if ( ! pByClient->IsPriv( PRIV_GM )) goto need_gm_privs; Broadcast(NULL, pszText, "", true); return; } case 8: // "WHEREIS" { WhereIs(pBy, pszText); return; } default: { TCHAR *pszMsg = Str_GetTemp(); sprintf(pszMsg, "Unknown command: '%s'", pszCommand); DecorateName(sFrom, NULL, true); pBy->SendChatMsg(CHATMSG_PlayerTalk, sFrom, pszMsg); return; } } }
// virtual void Properties::PropertyListener::handleEvent(System::Event* evt) { #if WIN32 if (evt->get_eventPhase() != System::CAPTURING_PHASE) { if (*evt->get_type() == L"contextmenu") { evt->stopPropagation(); UI::MouseEvent* mouseEvt = static_cast<UI::MouseEvent*>(evt); UI::CLXUIMenuElement* menu = new UI::CLXUIMenuElement(); // menu->SetRParent(m_ctledit); menu->SetOwnerWindow(mouseEvt->GetOwnerWindow()); menu->addEventListener(WSTR("command"), this, false); if (false) { menu->AddItem(new UI::TextString(WSTR("Display As Table")), 100); } else { Type* pType = m_pProperty->get_method->m_decl->m_pType->GetFunction()->m_pReturnType; if (pType->get_Kind() == type_pointer && pType->GetPointerTo()->get_Kind() == type_class) { vector<ClassType*> list; GetDerived(pType->GetPointerTo()->GetClass(), list); for (int i = 0; i < list.GetSize(); i++) { ClassType* pDerived = list[i]; if (pDerived->m_derived.GetSize() == 0) { menu->AddItem(new UI::TextString(pDerived->get_Name()->ToStringW()), (long)pDerived); } } } } menu->GetMenuPopup()->Popup(menu, LDraw::PointI(mouseEvt->get_ScreenX(), mouseEvt->get_ScreenY())); } else if (*evt->get_type() == L"command") { if (false) { m_bDisplayAsTable = !m_bDisplayAsTable; } else { evt->stopPropagation(); UI::CommandInvokeEvent* cmdEvt = dynamic_cast<UI::CommandInvokeEvent*>(evt); long param = cmdEvt->get_Command(); ClassType* pDerivedType = (ClassType*)param; void* p = newobj(pDerivedType); if (p) { Type* pType = m_pProperty->set_method->m_decl->m_pType->GetFunction()->m_parameters.m_parameters[0].m_pType; pType = pType->GetStripped(); void* value = DynamicCast(p, pDerivedType, pType->GetPointerTo()->GetClass()); ASSERT(0); void *_this = NULL;//__RTDynamicCast(m_itemVisual, 0, (void*)&typeid(m_itemVisual), (void*)m_pProperty->set_method->GetTypeInfo(), 0); // StringA str_type = pType->ToString(); ULONG_PTR func; if (m_pProperty->set_method->m_decl->m_offset != -1) { void* vtable = *(void**)_this; func = *(ULONG_PTR*)((uint8*)vtable + m_pProperty->set_method->m_decl->m_offset); } else { func = m_pProperty->set_method->m_func; } __asm { push ecx mov ecx,_this push value call func pop ecx } } } } #if 0 void *_this = __RTDynamicCast(m_itemVisual, 0, (void*)&typeid(m_itemVisual), (void*)put_type_info(), 0); cpp::Type* pType = put_decl->m_pType->m_pFunction->m_parameters[0]->m_pType; StringA str_type = pType->toString(); pType = pType->GetType(); DWORD func; if (put_decl->m_offset != -1) { void* vtable = *(void**)_this; func = *(DWORD*)((uint8*)vtable + put_decl->m_offset); } else { func = put_func; } if (*evt->get_type() == L"contextmenu") { evt->stopPropagation(); UI::MouseEvent* mouseEvt = dynamic_cast<MouseEvent*>(evt); if (pType->m_type == cpp::type_pointer && pType->m_pPointerTo->m_type == cpp::type_class) { CLXUIMenuElement* menu = new CLXUIMenuElement(); menu->SetRParent(m_ctledit); menu->SetOwnerWindow(m_ctledit->get_OwnerWindow()); std::map<StringA, cpp::Type*>::iterator it = pD->m_namedTypes.begin(); while (it != pD->m_namedTypes.end()) { cpp::Type* pType2 = (*it).second; ASSERT(pType2); it++; if (pType2->m_type == cpp::type_class) { if (pType2->m_pClass->IsOfType(pType->m_pPointerTo->m_pClass)) { // pType2->m_pClass->IsOfType(pType->m_pPointerTo->m_pClass); menu->AddItem(new TextString(ConvertA2S(pType2->m_pClass->m_name)), (long)pType2); } } } menu->GetMenuPopup()->Popup(menu, LDraw::PointI(mouseEvt->get_ScreenX(), mouseEvt->get_ScreenY())); } } else if (*evt->get_type() == L"command") { evt->stopPropagation(); CommandInvokeEvent* cmdEvt = dynamic_cast<CommandInvokeEvent*>(evt); long param = cmdEvt->get_Command(); if (pType->m_type == cpp::type_enum) { __asm { push ecx mov ecx,_this push param call func pop ecx } } else { cpp::Type* pType2 = (cpp::Type*)param; void* object = newobj(pType2->m_pClass); Type_Info* src = (Type_Info*)pD->LookupSymbol(DecorateName(pType2->m_pClass->m_name)); Type_Info* dst = (Type_Info*)pD->LookupSymbol(DecorateName(pType->m_pPointerTo->m_pClass->m_name)); void* param = __RTDynamicCast(object, 0, src, dst, 0); __asm { push ecx mov ecx,_this push param call func pop ecx } } } else if (*evt->get_type() == L"ValueChange")