#pragma once
#include "Jass.h"
#include "myJASSConstants.h"
#include "Game_structures.h"
#include "MapBases.h"

bool vWar3MapInit;
integer vMapGlobal;
char * pMapGlobal;
unsigned short vW = 128;
unsigned short vH = 128;
unsigned short vH2 = 4;
unsigned short vW2 = 4;
unsigned short vH3 = vH*vH2;
unsigned short vW3 = vW*vW2;
unsigned int vSizeMap = vH3 * vW3;
HHASHTABLE vHT_To_Analize_Work_Map;
TEventRegistrationHandle vMainThreadDestroyedHandle;
char vTest[1000];
int vFlagTest=0;

IdDataUnit vDataUnits[MAX_COUNT_UNITS];
unsigned short **vMapUnits;

integer vNLocalPlayer;
integer vStartCommands;
integer vStartCommandsGo;
HTRIGGER hTriggerUnitEntersWorldBoundsRegion;
HTRIGGER hTriggerFillMapUnits;

HLOCATION *hLocationMap;
//HLOCATION hLocationCenterCellMap[vSizeMap];

HTEXTTAG vTextTagMap;
HTEXTTAG vTextTag;
//HTEXTTAG *vTextTag2;
HTIMER vTimerGame;
HTIMER vTimerGamePre;
real vTimeActionFillMapUnits;

integer vSetHost;
integer vSetHostGo;
HPLAYER vHostPlayer = 0;
HPLAYERCOLOR vHost;

DataGoTo *pFirstDataGoTo;
DataGoTo *pLastDataGoTo;

HumanPlayer *pHumanPlayerGlobal;
VampirePlayer *pVampirePlayerGlobal;

integer vCountHumans;
integer vCountVampires;
integer vCountHumansUser;
integer vCountVampiresUser;

integer vGameBegin;

HTIMER vTimerActionsGame;

HTIMER *pTimerHuman;
HTIMER *pTiemrVampire;

HTRIGGER hTriggerEndGame;
HTRIGGER hTriggerEndGame2 = 0;
HTRIGGER hTriggerEndGame3;
HTRIGGER hTriggerChat;

unsigned short vLastUnit=NO_UNIT;

HHASHTABLE vHT;
integer vAuthorization;
integer vCountAttempts;

HREGION hRegionWorldBounds;
integer vWin;

HTRIGGER hTriggerWinPlayer[MAX_PLAYERS];

HRECT vWorldRect;
HRECT vManaWellRect;

char vIP[100];
bool bIP;

HTIMER vTimerForFogOfWar;

HTRIGGER hTriggerChatAI;

integer vEndGame2;

HGAMECACHE vSyncCache;
HGAMECACHE vSyncCache2;
HGAMECACHE vSyncCache3;
HGAMECACHE vSyncCache4;

HGAMECACHE vAuthorizationCache;

sPlayerUser *pPlayerUser;
integer vCountPlayersUser;

unsigned short vTopShop;
unsigned short vRecepts;
unsigned short vGate;
unsigned short vSven;
unsigned short vBansha;
unsigned short vManaWell;
unsigned short vWellOfLife;
unsigned short vBaseOfUnits;

sDataVampires * pDataVampires;
sDataHumans * pDataHumans;

unsigned short vMaxBase;

HRECT vBaseZeroRect;

//HTRIGGER hTriggerUnitLeaveWorldBoundsRegion;

MapBases vMapBases;

HRECT vBaseVampires;

HHASHTABLE vHT_2;

int vNumLog;

char vKeyLocalPlayer[3];

bool vSync;
bool vSync2;
bool vSync4;

int vCountForLoopGame;

sStackActions *vBundle;

char vBuf[300];

//sDataUnit2 *pCurrentCreateDataUnit;
//sDataUnit2 *pLastCreateDataUnit;
//sDataUnit2 *pCurrentDeleteDataUnit;
//sDataUnit2 *pLastDeleteDataUnit;
//sDataUnit2 vDataUnit2[MAX_COUNT_UNITS];
//unsigned short vNLastDataUnit2;
sActionStackForDelAndCreateUnit vActionStackForDelUnit;
sActionStackForDelAndCreateUnit vActionStackForCreateUnit;
sActionStackForDelAndCreateUnit vActionStackForCreateedUnit;
HTIMER vTimerDataUnit2;

StackForUnits vStackForUnits[MAX_COUNT_UNITS];
unsigned short vNLastStackForUnits;
unsigned short vQUnitsInBase[JASS_NumBase_MAX];

sStackChains vStackChains[MAX_COUNT_UNITS];
unsigned short vNLastStackChains;

bool vStartGameSleep;

HMODULE hJassApi;
HMODULE hJassApi_2;

//bool vSync4_Priority;

sDataUnit2 pDataUnit2;

HTIMER vTimerPreActionsGame;

HTIMER vTimerGameHumans;

sParamEndGame vParamEndGame;
HANDLE hThreadEndGame;

HTIMER vTimerPreBeginGameProcess;

TEventRegistrationHandle vEndGameHandle;

HTIMER vTimerMain;

bool vBoolId;

real vGlobalTimeActionAI[MAX_PLAYERS];

real vGlobalTimeAction;

integer vGlobalNAI;

real vTimerGetElapsedGlobal;

HumanPlayer * pHumanPlayer;

int vPriority;

sAction vMassActions[MAX_COUNT_UNITS];
int vNLastMassActions;