Now Auto targetting mode can be changed in the multiplayer game without network desync causes

This commit is contained in:
alyokhin 2021-04-19 19:44:50 +03:00
parent a24c6a8a60
commit 1effc1d224

View file

@ -42,6 +42,8 @@
#include "construct.h"
#include "interface.h"
#include "map.h"
#include "netconnect.h"
#include "network.h"
#include "pathfinder.h"
#include "player.h"
#include "script.h"
@ -1281,6 +1283,26 @@ static int CclSelectSingleUnit(lua_State *l)
return 0;
}
/**
** Enable/disable simplified auto targeting
**
** @param l Lua state.
**
** @return 0 for success, 1 for wrong type;
*/
static int CclEnableSimplifiedAutoTargeting(lua_State *l)
{
LuaCheckArgs(l, 1);
const bool isSimplified = LuaToBoolean(l, 1);
if (!IsNetworkGame()) {
Preference.SimplifiedAutoTargeting = isSimplified;
} else {
NetworkSendExtendedCommand(ExtendedMessageAutoTargetingDB,
int(isSimplified), 0, 0, 0, 0);
}
return 0;
}
/**
** Register CCL features for unit.
*/
@ -1315,6 +1337,7 @@ void UnitCclRegister()
lua_register(Lua, "SlotUsage", CclSlotUsage);
lua_register(Lua, "SelectSingleUnit", CclSelectSingleUnit);
lua_register(Lua, "EnableSimplifiedAutoTargeting", CclEnableSimplifiedAutoTargeting);
}
//@}