aboutsummaryrefslogtreecommitdiff
path: root/Engine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Engine.cpp')
-rw-r--r--Engine.cpp57
1 files changed, 32 insertions, 25 deletions
diff --git a/Engine.cpp b/Engine.cpp
index 3619af9..e3adeaa 100644
--- a/Engine.cpp
+++ b/Engine.cpp
@@ -72,7 +72,7 @@ PlayerArray* Engine::GetPlayerArray() const
Vector2 Engine::worldToScreen(Vector3 position) const
{
MainScreen* mainScreen = GetMainScreen();
- static int tileSize = GetWorld()->pMap->GetTileSize();
+ int tileSize = GetWorld()->pMap->GetTileSize();
float tile_width = tileSize * mainScreen->pGameScreen->pMainView->ScreenPosZ;
float tile_height = tileSize * mainScreen->pGameScreen->pMainView->ScreenPosZ;
@@ -92,7 +92,7 @@ Vector2 Engine::worldToScreen(Vector3 position) const
Vector2 Engine::worldToScreen(Unit* unit) const
{
- return worldToScreen(unit->position);
+ return worldToScreen(unit->GetPosition());
}
uint32_t Engine::GetPlayerColor(int colorIndex) const
@@ -162,6 +162,31 @@ Player* Engine::GetPlayer(int index) const
return playerArray->playerData[index].player;
}
+//TODO is this stable?
+int Engine::GetPlayerNumber(Player* player)
+{
+ const int64_t totalPlayers = GetTotalPlayers();
+
+
+ MainScreen* mainScreen = GetMainScreen();
+
+ World* main = GetWorld();
+
+ PlayerArray* playerArray = main->pPlayerArray;
+
+
+ for (int i = 0; i <= totalPlayers; i++)
+ {
+ if (playerArray->playerData[i].player == player)
+ {
+ return i;
+ }
+ }
+
+ printf("Failed to GetPlayerNumber()\n");
+ return -1;
+}
+
Player* Engine::GetPlayerByName(char* playerName) const
{
MainScreen* mainScreen = GetMainScreen();
@@ -209,21 +234,12 @@ Player* Engine::GetLocalPlayer() const
}
//
-//Pauses the game
-void Engine::PauseGame() const
-{
- typedef int64_t(__fastcall* tPauseGame)(CommHandler* CommHandler);
- static tPauseGame fPauseGame = (tPauseGame)(base + Offsets::pauseGame);
- fPauseGame(Get()->GetGame()->pCommHandler);
-}
-
-//
//Sends a chat message. Only to be called from rendering thread
void Engine::SendChat(const char* message, bool teamchat) const
{
typedef void(__fastcall* tSendChat) (int64_t game, const char* text);
- static tSendChat fSendChat = (tSendChat)(base + Offsets::sendChat);
- static int64_t game = *(int64_t*)(base + Offsets::pAVGame);
+ tSendChat fSendChat = (tSendChat)(base + Offsets::sendChat);
+ int64_t game = *(int64_t*)(base + Offsets::pAVGame);
if (teamchat)
{
@@ -239,22 +255,13 @@ void Engine::SendChat(const char* message, bool teamchat) const
void Engine::PrintNotification(const char* message) const
{
typedef void(__fastcall* tPrintNotification) (GameScreen* AVGameScreen, const char* message, int unknown);
- static tPrintNotification fPrintNotification = (tPrintNotification)(base + Offsets::printNotification);
- fPrintNotification(GetMainScreen()->pGameScreen, message, 1);
+ tPrintNotification fPrintNotification = (tPrintNotification)(base + Offsets::printNotification);
+ fPrintNotification(GetMainScreen()->pGameScreen, message, 0);
}
void Engine::PrintBottomNotification(const char* message, unsigned int hexcolor) const
{
typedef void(__fastcall* tPrintBottomText) (GameScreen* AVGameScreen, const char* message, unsigned int hexcolor, int64_t unused);
- static tPrintBottomText fPrintBottomText = (tPrintBottomText)(base + Offsets::printBottomText);
+ tPrintBottomText fPrintBottomText = (tPrintBottomText)(base + Offsets::printBottomText);
fPrintBottomText(GetMainScreen()->pGameScreen, message, hexcolor, 0xffffffffffffffff); //Color format: RBGA
}
-
-int64_t Engine::Flare(float xPos, float yPos) const
-{
- typedef __int64(__fastcall* tCreateFlare) (Player* player, __int64 hundert12, __int64 zero1, __int64 zero2, float xPos, float yPos, int64_t zero3, int64_t zero4);
- static tCreateFlare fCreateFlare = (tCreateFlare)(base + 0xc31270);
-
- return fCreateFlare(GetLocalPlayer(), 0x112, 0, 0, 220.f, 220.f, 0, 0);
- //__usercall fhsCreateFlare_MAYBE_7FF718CF1270@<rax>( __int64 a3_zero@<r8>, __int64 a4_zero@<r9>, float xPos@<xmm2>, float yPos@<xmm3>, __int64 a5_zero, int a6_Zero)
-}