Author Topic: 0.2.11-test2  (Read 3650 times)

daniel.santos

  • Guest
0.2.11-test2
« on: 14 December 2008, 04:11:21 »
Ok, here's 0.2.11-test2: http://http://glest.codemonger.org/downloads-table-0.2.11-test2.php.  It should fix the problem compiling on Utuntu 6.06.  It also includes the full keymap.ini to help avoid confusion.  It comes with the short version of glestadv.ini, but just run it once and it fills it out (plus doing the video card detection normally enabled by setting "FirstTime" to true).  You can set "MiscDebugKeys=true" now and the value of each keystroke (in GAE key codes) will be displayed to the console.  Thus, on non-english keyboards, you should get "Worldxx" for each key that's supported.  I'm not entirely certain what all determines that either.

Note that this is still intended for Linux as there are still problems on the windows build.  As soon as I get those fixed, I'll probably be releasing 0.2.11.  Thanks for all who've tested and helped!

@kukac@

  • Guest
Re: 0.2.11-test2
« Reply #1 on: 14 December 2008, 11:56:20 »
Interesting, when I opened that link, it gave me the old test1...

daniel.santos

  • Guest
Re: 0.2.11-test2
« Reply #2 on: 14 December 2008, 21:27:58 »
bah, crap, I messed something up, sorry.

Ok, I'm re-running the release script now.  I accidentally fed it the old version when I ran it yesterday, the link should be fixed in a few minutes.

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
Re: 0.2.11-test2
« Reply #3 on: 14 December 2008, 22:02:22 »
Update:
Damn it doesn't build .....
I get

glest_game/facilities/pos_iterator.cpp:46: Fehler: »qsort« wurde in diesem Gültigkeitsbereich nicht definiert
In english something like:
glest_game/facilities/pos_iterator.cpp:46: Error: »qsort« wasn't defined in this scope
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

daniel.santos

  • Guest
Re: 0.2.11-test2
« Reply #4 on: 14 December 2008, 23:19:34 »
:(

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
Re: 0.2.11-test2
« Reply #5 on: 14 December 2008, 23:23:24 »
it works !
thanks
I will test it now.
Should I test multiplayer too?
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

daniel.santos

  • Guest
Re: 0.2.11-test2
« Reply #6 on: 14 December 2008, 23:48:12 »
Yea, actually that would help a lot titi, thanks! :)  I'll make sure I add that include in the code too to avoid this problem in the future.

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
Re: 0.2.11-test2
« Reply #7 on: 14 December 2008, 23:59:27 »
ok i made one first little test with one first little game( one easy whole match ).
I didn't see any pproblems in singleplayer and the keys are working( I don't really tried a lot here )
Its proabaly a little bit slower, but I'm not shure with this. I have to compare it to older versions tomorrow.
Its late here and I have to go to bed now. I will test more with my boys tomorrow and give you as much feed back as possible then.
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

hailstone

  • Local Moderator
  • Battle Machine
  • ********
  • Posts: 1,568
    • View Profile
Re: 0.2.11-test2
« Reply #8 on: 18 December 2008, 03:03:45 »
If it works how I think it should, the ini file would be read into memory so it shouldn't be much slower.

I had a look at the source but don't really understand it completely. Why are there so many values in the table? Is there not a simpler way?. I should learn about assert too.
Glest Advanced Engine - Admin/Programmer
https://sourceforge.net/projects/glestae/

daniel.santos

  • Guest
RE: Keymap code
« Reply #9 on: 18 December 2008, 04:50:43 »
The keymap.ini file is read at startup and the values are indeed stored in memory (by my calculations, it takes 1568 bytes + various overhead, essentially less than 2k).

Well, the asserts are only compiled into the code if you are making a real debug build -- more specifically, if you have the preprocessor manifest constant "DEBUG" (without the quotes) defined.  In gcc, this is defined with -DDEBUG and it doesn't need a value, it's just defined.  When an assert() statement is compiled when DEBUG is not defined, it is completely compiled out (i.e., produces no code at all).  Thus, it's a good way to add sanity checks that don't have any impact (code size, speed, etc.) in a release build.  If the expression contained in an assert() statement is not true at run-time, then the failure is written to standard out and a breakpoint interrupt is set, on x86(_64), this is "int 3" (software interrupt number 3).

The sheer size of the file input.cpp is due to trade offs.  I could write a set of functions to do this, but it would be slower and most likely make for larger code.  I suppose this was more true when the KeyCode type could be stored in a single byte, unfortunately there are more than 256 values now, so I changed it to a short.  Even so, each line in the initialization of the native2kc and kc2native arrays only takes 2 bytes, even though there is much more text than that.  If you notice the "#pragma pack(push, 1)" and "#pragma pack(pop)" that surrounds the initialization, that's what tells the compiler not to align fields as it normally would (usually on a 4 byte barrier), but to pack them together.  Further, that data is never loaded into memory more than once (only when that data segment of the executable is loaded).  Thus, the mechanism I've employed here has the following benefits:
  • smaller executable file
  • less memory used at runtime
  • fastest possible mechanism (actually, it could be faster to not pack the fields, but would take 2-4 times the memory! and then we get into the CPU cache hit question)
and the following costs:
  • huge code file
  • huge pain to maintain - I actually created this code in an OpenOffice spreadsheet!!  Any changes (especially inserting values) will require tedious work to make sure everything still lines up (more so in the array initialization, the asserts just use the symbols and will make sure we didn't mess it up)
In the end, I decided that the benefits outweighed the costs and went with the smaller faster code.

So that part is just input.h/cpp and the classes Shared::Platform::Key and Shared::Platform::Input.  The Keymap is implemented in glest_game/gui/keymap.h/cpp.  The fact of the folder being "gui" and not "ui" makes it a little odd, but it is part of the user interface, so this appears to be the most appropriate place for it.

So the keymap allows 1 or 2 key combinations (KeyCode and modifiers) to be mapped to a command.  KeyCode is an enum defined in shared/include/platform/input.h and is essentially a platform-neutral / GAE-specific definition for each key that is compatible with both SDL and windows.  The modifiers for the Keymap are defined in the BasicKeyModifier enum, a different one used in the input.h/cpp which may or may not be a good idea, but it's the way it is now (and can be changed/healed/refactored later) and is a bitmask rather than a true enumeration.  Bits can be ORed together, etc.  So each Keymap::Entry object specifies both a Key and the modifiers (i.e., shift, control, alt, etc.) and each command can be mapped to up to two key combinations, so I created an EntryPair class to encapsulate that so the pair of entries can be dealt with as a single entity.  These are the classes that are used during execution of actual game play.

Then you will notice that there is a UserCommandInfo structure with another initialization table in keymap.cpp.  This is used for initialization of default values.  You'll notice that I packed these as well, that's to save space in the executable and memory, although this is only read when the game starts up and that memory page can be unloaded once game play starts (and your OS's kernel might do just that if it needs the memory).

So then that just leaves the actual mechanism used for everything
Code: [Select]
vector<EntryPair> entries;
map<Entry, UserCommand> entryCmdMap;
the classes vector and map are from STL (Standard Template Library).  The vector is essentially a dynamic, resizable array and the map maps a "key" object to a "value" object.  So the "entries" vector contains one EntryPair object for each command and is mapped to command such that entries[cmd] will be the EntryPair for that command.  The "entryCmdMap" maps each individual (non-empty) Entry object to a command, as a sort of cross-reference.  This way, I can look up the EntryPair for a specific command quickly (using entries[cmd]) and I can also specify an Entry (key combination) and find out quickly if any command is mapped to it or not (using entryCmdMap[Entry(keyIPressed, modifierKeysDown)]).  The "entries" vector is a sort-of master table and the entryCmdMap is essentially an index and it's rebuild by calling Keymap::reinit(), which once there is a UI for editing mappings, will need to be done each time after mappings are changed.

So the rest of the code is basic, straight-forward OO stuff, the Keymap constructor calls loads default values, the EntryPair constructor accepts the UserCommandInfo struct to initialize its self, the Keymap::load() calls EntryPair::init() which in turn calls Entry::init(), etc.

I hope that helps it make more sense.

hailstone

  • Local Moderator
  • Battle Machine
  • ********
  • Posts: 1,568
    • View Profile
Re: 0.2.11-test2
« Reply #10 on: 20 December 2008, 04:34:49 »
Thanks for explaining.

PS: I've made a heading in the wikia for links to posts like this. https://docs.megaglest.org/Glest_Advan ... xplanation
« Last Edit: 18 June 2016, 14:56:02 by filux »
Glest Advanced Engine - Admin/Programmer
https://sourceforge.net/projects/glestae/

horusofoz

  • Guest
Re: 0.2.11-test2
« Reply #11 on: 20 December 2008, 09:33:16 »
Is it possible to get a pre-compiled version for windows? I've looked around on the forums and seen all these great ideas but haven't been able to see any in action as I use windows have absolutely NO idea about coding or compiling. Still I would like to try out the GAE and give my feedback from more than theoretical point of view.

Thanks  :)

wciow

  • Behemoth
  • *******
  • Posts: 968
    • View Profile
Re: 0.2.11-test2
« Reply #12 on: 20 December 2008, 10:32:02 »
Go here for the (almost) latest version:  http://glest.codemonger.org/
Check out my new Goblin faction - https://forum.megaglest.org/index.php?topic=9658.0

horusofoz

  • Guest
Re: 0.2.11-test2
« Reply #13 on: 20 December 2008, 12:11:16 »
Didn't work for me :(

Oh well I'll have to wait for a more polished release. Still thanks for the help and hope you guys keep up the good work:-)

daniel.santos

  • Guest
Re: 0.2.11-test2
« Reply #14 on: 22 December 2008, 06:26:39 »
Quote from: hailstone
Thanks for explaining.

PS: I've made a heading in the wikia for links to posts like this. https://docs.megaglest.org/Glest_Advan ... xplanation
good idea!  Thanks! :)

horusofoz , the 0.2.11 *should* work on windows, but network play is still pretty messy.
« Last Edit: 18 June 2016, 13:00:58 by filux »

 

anything