mirror of
https://github.com/whoahq/whoa.git
synced 2026-03-18 13:41:06 +03:00
Compare commits
5 Commits
4430449ad2
...
a9e314b16d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a9e314b16d | ||
|
|
cda8fff096 | ||
|
|
5ee4c54827 | ||
|
|
68ad71090e | ||
|
|
a82628adaa |
@ -160,6 +160,10 @@ ClientConnection* ClientServices::Connection() {
|
||||
return ClientServices::s_currentConnection;
|
||||
}
|
||||
|
||||
void ClientServices::CharacterDelete(uint64_t guid) {
|
||||
ClientServices::Connection()->RequestCharacterDelete(guid);
|
||||
}
|
||||
|
||||
void ClientServices::Disconnect() {
|
||||
ClientServices::Connection()->Disconnect();
|
||||
}
|
||||
|
||||
@ -33,6 +33,7 @@ class ClientServices : public LoginResponse {
|
||||
// Static functions
|
||||
static void ConnectToSelectedServer();
|
||||
static ClientConnection* Connection();
|
||||
static void CharacterDelete(uint64_t guid);
|
||||
static void Disconnect();
|
||||
static const char* GetCurrentLoginPortal();
|
||||
static const char* GetCurrentLoginServer();
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
#include "glue/CCharacterSelectionScript.hpp"
|
||||
#include "CGlueMgr.hpp"
|
||||
#include "db/Db.hpp"
|
||||
#include "glue/CCharacterSelection.hpp"
|
||||
#include "object/client/CGUnit_C.hpp"
|
||||
@ -157,7 +158,17 @@ int32_t Script_SelectCharacter(lua_State* L) {
|
||||
}
|
||||
|
||||
int32_t Script_DeleteCharacter(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
if (!lua_isnumber(L, 1)) {
|
||||
luaL_error(L, "Usage: DeleteCharacter(index)");
|
||||
}
|
||||
|
||||
int32_t index = static_cast<int32_t>(lua_tonumber(L, 1)) - 1;
|
||||
|
||||
if (index >= 0 && index < CCharacterSelection::s_characterList.Count()) {
|
||||
CGlueMgr::DeleteCharacter(CCharacterSelection::s_characterList.m_data[index].m_info.guid);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t Script_RenameCharacter(lua_State* L) {
|
||||
|
||||
@ -129,6 +129,17 @@ void CGlueMgr::ChangeRealm(const REALM_INFO* realmInfo) {
|
||||
ClientServices::Connection()->Connect();
|
||||
}
|
||||
|
||||
void CGlueMgr::DeleteCharacter(uint64_t guid) {
|
||||
if (guid) {
|
||||
CGlueMgr::SetIdleState(IDLE_DELETE_CHARACTER);
|
||||
|
||||
auto text = FrameScript_GetText(ClientServices::GetErrorToken(70), -1, GENDER_NOT_APPLICABLE);
|
||||
FrameScript_SignalEvent(OPEN_STATUS_DIALOG, "%s%s", "CANCEL", text);
|
||||
|
||||
ClientServices::CharacterDelete(guid);
|
||||
}
|
||||
}
|
||||
|
||||
void CGlueMgr::EnterWorld() {
|
||||
if (!ClientServices::GetSelectedRealm()) {
|
||||
return;
|
||||
|
||||
@ -66,6 +66,7 @@ class CGlueMgr {
|
||||
// Static functions
|
||||
static void CancelRealmListQuery();
|
||||
static void ChangeRealm(const REALM_INFO* realmInfo);
|
||||
static void DeleteCharacter(uint64_t guid);
|
||||
static void DisplayLoginStatus();
|
||||
static void EnterWorld();
|
||||
static void GetCharacterList();
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#include "net/connection/ClientConnection.hpp"
|
||||
#include "net/Login.hpp"
|
||||
#include "client/ClientServices.hpp"
|
||||
#include "common/datastore/CDataStore.hpp"
|
||||
#include "net/Login.hpp"
|
||||
#include "ui/FrameScript.hpp"
|
||||
|
||||
void ClientConnection::AccountLogin(const char* name, const char* password, int32_t region, WOW_LOCALE locale) {
|
||||
@ -160,3 +161,19 @@ int32_t ClientConnection::PollStatus(WOWCS_OPS& op, const char** msg, int32_t& r
|
||||
|
||||
return this->m_statusComplete;
|
||||
}
|
||||
|
||||
void ClientConnection::RequestCharacterDelete(uint64_t guid) {
|
||||
this->Initiate(COP_DELETE_CHARACTER, 70, nullptr);
|
||||
|
||||
if (this->IsConnected()) {
|
||||
CDataStore netMsg;
|
||||
netMsg.Put(static_cast<uint32_t>(CMSG_CHAR_DELETE));
|
||||
netMsg.Put(guid);
|
||||
netMsg.Finalize();
|
||||
|
||||
this->Send(&netMsg);
|
||||
}
|
||||
else {
|
||||
this->Cancel(4);
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,6 +43,7 @@ class ClientConnection : public RealmConnection {
|
||||
void Initiate(WOWCS_OPS op, int32_t errorCode, void (*cleanup)());
|
||||
int32_t IsConnected();
|
||||
int32_t PollStatus(WOWCS_OPS& op, const char** msg, int32_t& result, int32_t& errorCode);
|
||||
void RequestCharacterDelete(uint64_t guid);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -41,6 +41,10 @@ uint32_t CGPlayer::TotalRemoteFieldsSaved() {
|
||||
return CGPlayer::GetBaseOffsetSaved() + 173;
|
||||
}
|
||||
|
||||
uint32_t CGPlayer::GetMoney() const {
|
||||
return this->Player()->coinage;
|
||||
}
|
||||
|
||||
uint32_t CGPlayer::GetNextLevelXP() const {
|
||||
return this->Player()->nextLevelXP;
|
||||
}
|
||||
|
||||
@ -149,6 +149,7 @@ class CGPlayer {
|
||||
static uint32_t TotalRemoteFieldsSaved();
|
||||
|
||||
// Public member functions
|
||||
uint32_t GetMoney() const;
|
||||
uint32_t GetNextLevelXP() const;
|
||||
uint32_t GetXP() const;
|
||||
|
||||
|
||||
@ -6,6 +6,12 @@
|
||||
#include "ui/Game.hpp"
|
||||
#include <storm/Error.hpp>
|
||||
|
||||
CGPlayer_C* CGPlayer_C::GetActivePtr() {
|
||||
return static_cast<CGPlayer_C*>(
|
||||
ClntObjMgrObjectPtr(ClntObjMgrGetActivePlayer(), TYPE_PLAYER, __FILE__, __LINE__)
|
||||
);
|
||||
}
|
||||
|
||||
CGPlayer_C::CGPlayer_C(uint32_t time, CClientObjCreate& objCreate) : CGUnit_C(time, objCreate) {
|
||||
// TODO
|
||||
}
|
||||
@ -14,20 +20,28 @@ CGPlayer_C::~CGPlayer_C() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
uint32_t CGPlayer_C::GetActiveNextLevelXP() const {
|
||||
uint32_t CGPlayer_C::GetMoney() const {
|
||||
if (this->GetGUID() != ClntObjMgrGetActivePlayer()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return this->GetNextLevelXP();
|
||||
return this->CGPlayer::GetMoney();
|
||||
}
|
||||
|
||||
uint32_t CGPlayer_C::GetActiveXP() const {
|
||||
uint32_t CGPlayer_C::GetNextLevelXP() const {
|
||||
if (this->GetGUID() != ClntObjMgrGetActivePlayer()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return this->GetXP();
|
||||
return this->CGPlayer::GetNextLevelXP();
|
||||
}
|
||||
|
||||
uint32_t CGPlayer_C::GetXP() const {
|
||||
if (this->GetGUID() != ClntObjMgrGetActivePlayer()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return this->CGPlayer::GetXP();
|
||||
}
|
||||
|
||||
void CGPlayer_C::PostInit(uint32_t time, const CClientObjCreate& init, bool a4) {
|
||||
|
||||
@ -10,13 +10,17 @@ class CreatureModelDataRec;
|
||||
|
||||
class CGPlayer_C : public CGUnit_C, public CGPlayer {
|
||||
public:
|
||||
// Public static functions
|
||||
static CGPlayer_C* GetActivePtr();
|
||||
|
||||
// Virtual public member functions
|
||||
virtual ~CGPlayer_C();
|
||||
|
||||
// Public member functions
|
||||
CGPlayer_C(uint32_t time, CClientObjCreate& objCreate);
|
||||
uint32_t GetActiveNextLevelXP() const;
|
||||
uint32_t GetActiveXP() const;
|
||||
uint32_t GetMoney() const;
|
||||
uint32_t GetNextLevelXP() const;
|
||||
uint32_t GetXP() const;
|
||||
void PostInit(uint32_t time, const CClientObjCreate& init, bool a4);
|
||||
void PostInitActivePlayer();
|
||||
void SetStorage(uint32_t* storage, uint32_t* saved);
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
#include <common/MD5.hpp>
|
||||
|
||||
WOWGUID CGGameUI::s_currentObjectTrack;
|
||||
uint32_t CGGameUI::s_cursorMoney;
|
||||
CScriptObject* CGGameUI::s_gameTooltip;
|
||||
bool CGGameUI::s_inWorld;
|
||||
WOWGUID CGGameUI::s_lockedTarget;
|
||||
@ -94,6 +95,10 @@ WOWGUID& CGGameUI::GetCurrentObjectTrack() {
|
||||
return CGGameUI::s_currentObjectTrack;
|
||||
}
|
||||
|
||||
uint32_t CGGameUI::GetCursorMoney() {
|
||||
return CGGameUI::s_cursorMoney;
|
||||
}
|
||||
|
||||
WOWGUID& CGGameUI::GetLockedTarget() {
|
||||
return CGGameUI::s_lockedTarget;
|
||||
}
|
||||
|
||||
@ -15,6 +15,7 @@ class CGGameUI {
|
||||
// Static functions
|
||||
static void EnterWorld();
|
||||
static WOWGUID& GetCurrentObjectTrack();
|
||||
static uint32_t GetCursorMoney();
|
||||
static WOWGUID& GetLockedTarget();
|
||||
static void Initialize();
|
||||
static void InitializeGame();
|
||||
@ -25,6 +26,7 @@ class CGGameUI {
|
||||
|
||||
private:
|
||||
static WOWGUID s_currentObjectTrack;
|
||||
static uint32_t s_cursorMoney;
|
||||
static bool s_inWorld;
|
||||
static WOWGUID s_lockedTarget;
|
||||
static bool s_loggingIn;
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#include "gx/Coordinate.hpp"
|
||||
#include "ui/FrameScript.hpp"
|
||||
#include "ui/ScriptFunctionsShared.hpp"
|
||||
#include "ui/game/CGGameUI.hpp"
|
||||
#include "ui/simple/CSimpleTop.hpp"
|
||||
#include "util/StringTo.hpp"
|
||||
#include "util/Unimplemented.hpp"
|
||||
@ -502,7 +503,9 @@ int32_t Script_ForceQuit(lua_State* L) {
|
||||
}
|
||||
|
||||
int32_t Script_GetCursorMoney(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
lua_pushnumber(L, CGGameUI::GetCursorMoney());
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int32_t Script_DropCursorMoney(lua_State* L) {
|
||||
|
||||
@ -189,7 +189,7 @@ int32_t Script_UnitXP(lua_State* L) {
|
||||
float xp = 0.0f;
|
||||
|
||||
if (unit && unit->IsA(TYPE_PLAYER)) {
|
||||
xp = static_cast<CGPlayer_C*>(unit)->GetActiveXP();
|
||||
xp = static_cast<CGPlayer_C*>(unit)->GetXP();
|
||||
}
|
||||
|
||||
lua_pushnumber(L, xp);
|
||||
@ -209,7 +209,7 @@ int32_t Script_UnitXPMax(lua_State* L) {
|
||||
float xpMax = 0.0f;
|
||||
|
||||
if (unit && unit->IsA(TYPE_PLAYER)) {
|
||||
xpMax = static_cast<CGPlayer_C*>(unit)->GetActiveNextLevelXP();
|
||||
xpMax = static_cast<CGPlayer_C*>(unit)->GetNextLevelXP();
|
||||
}
|
||||
|
||||
lua_pushnumber(L, xpMax);
|
||||
@ -282,7 +282,15 @@ int32_t Script_UnitLevel(lua_State* L) {
|
||||
}
|
||||
|
||||
int32_t Script_GetMoney(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
auto player = CGPlayer_C::GetActivePtr();
|
||||
|
||||
if (player) {
|
||||
lua_pushnumber(L, player->GetMoney());
|
||||
} else {
|
||||
lua_pushnumber(L, 0.0f);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int32_t Script_GetHonorCurrency(lua_State* L) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user