Patch for multiple group AIs in one DLL

Patch for multiple group AIs in one DLL

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
Jack
Posts: 32
Joined: 15 Jul 2006, 00:35

Patch for multiple group AIs in one DLL

Post by Jack »

I've written a patch for spring to allow multiple AIs in a single DLL. I've tested it with the latest version from SVN. It includes an update to the interface version number, the changelog and the existing group AIs (the interface has changed slightly). This has been done to support group AIs that aren't written in C++ and are accessed through a proxy DLL.

http://www.jwhitham.org.uk/pyai/multi_ais_per_dll.diff

Here is a test AI for it - it's all five of the group AIs in SVN, rolled into a single DLL. The new DLL looks exactly the same as its five constituents from within Spring.

http://www.jwhitham.org.uk/pyai/allais.tar.gz

Details: The new code works by replacing GetAiName with GetAiNameList, which returns a list of the AIs present in the DLL: a list of length 1 for the existing group AIs. The index number of each AI within this list is used to identify each AI during calls to IsUnitSuited, GetNewAI, and ReleaseAI.

Any comments? Please post below. Thanks!
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Post by imbaczek »

Only useful comment I can give, given my zero knowledge of Spring code - unified diffs are (IMHO) a lot more human readable 8)
Jack
Posts: 32
Joined: 15 Jul 2006, 00:35

Post by Jack »

imbaczek wrote:Only useful comment I can give, given my zero knowledge of Spring code - unified diffs are (IMHO) a lot more human readable 8)
Having now seen the results of using -U, I would tend to agree. I have updated the file.
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen »

Ehm, can you change it back? :)
My tortoisesvn doesn't like it. It also doesn't have revision numbers which seems wrong. In theory it could check dates but it doesn't work at all anyway.
So a normal patch plz:)
Jack
Posts: 32
Joined: 15 Jul 2006, 00:35

Post by Jack »

jcnossen wrote:Ehm, can you change it back? :)
My tortoisesvn doesn't like it. It also doesn't have revision numbers which seems wrong. In theory it could check dates but it doesn't work at all anyway.
So a normal patch plz:)
Hi, sorry it didn't work. http://www.jwhitham.org.uk/pyai/multi_a ... dll_2.diff is a regular diff (just 'diff -r'). Hope that works better. If not, is there a particular way of doing this? I
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

Generating it with tortoise svn always worked fine for me.....
Jack
Posts: 32
Joined: 15 Jul 2006, 00:35

Post by Jack »

Is my new patch usable? Do let me know, when you have a chance to look at it, as I am quite happy to change it.
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen »

svn still expects a "Index" to indicate files at the start of the diff/patch. So you have to try again :/ The standard Create Patch of TortoiseSVN or SmartSVN should both work ok.
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Post by Tobi »

I'm pretty sure I can apply it (using patch), it's a standard unified diff and apparently tortoise expects some custom format...
Jack
Posts: 32
Joined: 15 Jul 2006, 00:35

Post by Jack »

Ah, I got it now. http://www.jwhitham.org.uk/pyai/multi_a ... l_svn.diff

I was using regular Unix diff, but I should have been using 'svn diff'. Thanks for your help.. hope it works now.
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Post by Tobi »

Could you fix indentation? (use tabs instead of spaces, open patch in browser to easily see where)

The code itself looks fine, I didn't spot obvious problems.
Jack
Posts: 32
Joined: 15 Jul 2006, 00:35

Post by Jack »

Tobi wrote:Could you fix indentation? (use tabs instead of spaces, open patch in browser to easily see where)

The code itself looks fine, I didn't spot obvious problems.
Done - new patch at http://www.jwhitham.org.uk/pyai/multi_a ... l_svn.diff
Also I have noticed that 'svn diff' does not include new files created by the patch. This patch requires one new file, trunk/rts/ExternalAI/aikey.h. This file is at http://www.jwhitham.org.uk/pyai/aikey.h - its contents could be merged into another, e.g. aibase.h, but it seemed cleaner to create a new file.
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Post by Tobi »

I think you can use "svn add filename" before "svn diff" to have the file included in the patch. Thanks for fixing indentation.
Jack
Posts: 32
Joined: 15 Jul 2006, 00:35

Post by Jack »

Tobi wrote:I think you can use "svn add filename" before "svn diff" to have the file included in the patch. Thanks for fixing indentation.
Ah, I'll remember that. Anyway, hopefully you have everything now.. do let me know if any problems show up as I will be happy to fix them.
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Post by Tobi »

Committed
User avatar
Acidd_UK
Posts: 963
Joined: 23 Apr 2006, 02:15

Post by Acidd_UK »

/me applauds magical Jack and awards him some jammy dodgers :-)
Post Reply

Return to “Engine”