Copy some synced gadget callins to unsynced

Copy some synced gadget callins to unsynced

Requests for features in the spring code.

Moderator: Moderators

Post Reply
User avatar
SpliFF
Posts: 1224
Joined: 28 Jul 2008, 06:51

Copy some synced gadget callins to unsynced

Post 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?
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6241
Joined: 29 Apr 2005, 01:14

Re: Copy some synced gadget callins to unsynced

Post 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)
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Copy some synced gadget callins to unsynced

Post 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)
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: Copy some synced gadget callins to unsynced

Post 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.)
User avatar
SpliFF
Posts: 1224
Joined: 28 Jul 2008, 06:51

Re: Copy some synced gadget callins to unsynced

Post 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++.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Copy some synced gadget callins to unsynced

Post by smoth »

ah, I misunderstood, I thought you were talking about unsynced in general, sorry for the that.
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Copy some synced gadget callins to unsynced

Post 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?
User avatar
Das Bruce
Posts: 3544
Joined: 23 Nov 2005, 06:16

Re: Copy some synced gadget callins to unsynced

Post by Das Bruce »

No, there will always be trolls.
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: Copy some synced gadget callins to unsynced

Post 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.
Post Reply

Return to “Feature Requests”