Page 1 of 1
Copy some synced gadget callins to unsynced
Posted: 16 Nov 2011, 13:45
by SpliFF
I'm writing a LuaAI that uses Tobi's framework (from C.R.A.I.G) to run unsynced. A large portion of the "framework" code is dedicated to serialising and forwarding some synced callins to unsynced.
I'm thinking though that most, if not all, of these callins would also make sense as unsynced versions done engine-side and this would alleviate a lot of messy serialisation. The unit callins would require allyTeam and/or LOS filtering.
The forwarded callins are:
Code: Select all
-- These callins happen on the synced side but must be forwarded to unsynced
local syncedCallInList = {
"GamePreload",
"GameStart",
"GameFrame",
"TeamDied",
"UnitCreated",
"UnitFinished",
"UnitDestroyed",
"UnitTaken",
"UnitGiven",
"UnitIdle",
}
NOTE: The C.R.A.I.G code is kinda old, maybe some of these are already available unsynced?
Re: Copy some synced gadget callins to unsynced
Posted: 16 Nov 2011, 19:45
by FLOZi
Might even be the case that CRAIG purposefully forwards them to avoid ally / los filtering? (I don't know, can't remember if I even ever did know)
Re: Copy some synced gadget callins to unsynced
Posted: 16 Nov 2011, 20:28
by smoth
FLOZi wrote:Might even be the case that CRAIG purposefully forwards them to avoid ally / los filtering? (I don't know, can't remember if I even ever did know)
^this. It is easy enough to hack spring, please be careful about how much you open up spring to exploits. None of our games will ever be competive as it is due to the ability to easily alter spring(open source code after all)
Re: Copy some synced gadget callins to unsynced
Posted: 16 Nov 2011, 21:15
by Tobi
FLOZi wrote:Might even be the case that CRAIG purposefully forwards them to avoid ally / los filtering? (I don't know, can't remember if I even ever did know)
No, there is no way to get those events in unsynced without forwarding them.
However, CRAIG purposefully does not do any ally / los filtering, as it has been moved into unsynced Lua code mostly to prevent having to deal with running synced.
(And not to make it behave like a human with scouts and stuff.)
Re: Copy some synced gadget callins to unsynced
Posted: 17 Nov 2011, 01:42
by SpliFF
This discussion is not relevant to cheating because we're talking about unsynced gadgets here, not widgets. The first 4 callins have no potential for cheating at all (how does knowing when the game started or a team died give you an advantage)? To open up cheating you'd need a gadget in your game forwarding data to widgets.
My proposal for the unit callins is simply that the data be made available to an unsynced gadget, preferably with an option to filter it by team and or LOS. The primary application for this would be non-cheating Lua AIs (which run synced and can cheat their hearts out anyway if they wanted to).
Tobi's code forwards data for unseen/enemy units via serialisation to string -> sendToUnsynced -> RecvFromSynced -> deserialisation which is expensive enough but then that data alsos need to be team/los filtered in Lua for a non-cheating AI. Given all this overhead a case exists for doing it in C++.
Re: Copy some synced gadget callins to unsynced
Posted: 17 Nov 2011, 01:58
by smoth
ah, I misunderstood, I thought you were talking about unsynced in general, sorry for the that.
Re: Copy some synced gadget callins to unsynced
Posted: 17 Nov 2011, 12:23
by Jools
The best way to prevent cheating btw is not by code, but by educating the playerbase that it's unsportsmanlike. There will always be ways to cheat, but that doesn't mean people will do it. Who wants to win that way anyway?
Re: Copy some synced gadget callins to unsynced
Posted: 17 Nov 2011, 12:45
by Das Bruce
No, there will always be trolls.
Re: Copy some synced gadget callins to unsynced
Posted: 17 Nov 2011, 14:37
by Tobi
SpliFF wrote:Tobi's code forwards data for unseen/enemy units via serialisation to string -> sendToUnsynced -> RecvFromSynced -> deserialisation which is expensive enough but then that data alsos need to be team/los filtered in Lua for a non-cheating AI. Given all this overhead a case exists for doing it in C++.
Wrong, no serialisation / deserialisation happens.
SendToUnsynced isn't more than a call-out in synced which synchronously calls the RecvFromSynced call-in in unsynced, only after checking that all the arguments are simple types (no tables, threads, functions).
So the overhead is a few extra function calls only: Spring, calls synced gadgetHandler, calls synced gadget, calls SendToUnsynced, calls unsynced gadgetHandler, calls unsynced gadget.
https://github.com/tvo/craig/blob/maste ... k.lua#L135
https://github.com/spring/spring/blob/d ... e.cpp#L252
https://github.com/spring/spring/blob/d ... e.cpp#L302
The serialisation you have seen in CRAIG is for the other way round: to send information from unsynced to synced. This needs to be serialised, because to send anything from unsynced to synced it must travel over the network so that all clients get the same message from unsynced at the same time.