MegaGlest Forum

Archives (read only) => Vanilla Glest => Multiplayer => Topic started by: PolitikerNEU on 23 August 2009, 08:33:33

Title: Glest with observers
Post by: PolitikerNEU on 23 August 2009, 08:33:33
Hello everyone, I made a "hack" to allow glest to have observers.

Code: [Select]
[url=http://billhome.at/glest/glestf.zip]http://billhome.at/glest/glestf.zip[/url]
You can now choose a team "Observer" (you have to add the Observer-String to your .lng or it will appear as ???Observer???) which doesn't play but has no fog of war.

There are many flaws including incorrect handling of <4-Player maps, the player taking a slot and the observer always getting the "You-Lose"-Messagebox instead of a neutral game-end-messagebox.

EDIT: I have updated the zip to fix the Mouse-movement bug

EDIT II: Fixed the missing #include <cstdio>

EDIT III: Glest is dead ==> used megaglest (no, I won't update it for each megaglest version)

Patch to megaglest (Rev 159):
Code: [Select]
http://billhome.at/glest/observer_hack_megaglest.patch
Patched source folder (Rev 159)
Code: [Select]
http://billhome.at/glest/observer_hack_megaglest_source_159.zip
The patched glest binary (Ubuntu 10.04, 32bit)
Code: [Select]
http://billhome.at/glest/glest.bin
Title: Re: Glest with observers
Post by: wciow on 23 August 2009, 12:28:19
Awesome, hopefully this can make it into the next release of GAE  :)
Title: Re: Glest with observers
Post by: Platyhelminth on 24 August 2009, 17:40:13
This source was not complete and may not allow win to compile:

here is the complete source (with the hack) :
Code: [Select]
http://billhome.at/glest/glest.zip
Title: Re: Glest with observers
Post by: Omega on 1 September 2009, 18:06:58
Fantastic!

But what about windows?!?

It would need more bug testing as well, but regarless, that is a good idea, and might be great for learning sessions. For example, someone could teach someone how to beat ultra AIs while the other guy spectators.
Title: Re: Glest with observers
Post by: ElimiNator on 1 September 2009, 18:20:04
But what about windows?!?

What about it!
Title: Re: Glest with observers
Post by: Platyhelminth on 1 September 2009, 18:42:15
But what about windows?!?

Every one who knows how to compile in windows is welcome to do it if he wants.
Title: Re: Glest with observers
Post by: assassin on 1 September 2009, 19:36:40
Yeah, why do windows users expect everything pre-compiled?
Title: Re: Glest with observers
Post by: Hectate on 1 September 2009, 21:15:36
Be cause we either don't know how, don't feel inclined to learn, or don't care about it if we have to put an effort into it  ;D

Seriously though, I haven't taken the time to practice compiling myself, although I have successfully in the past with proper instructions.
Title: Re: Glest with observers
Post by: assassin on 2 September 2009, 07:42:59
there is something in the glest wiki about compiling glest in windows, why don't you look there?
What annoys me is the way people go "Oh look it's some C++ code! It must be for linux users because we windows users are above compiling"
Title: Re: Glest with observers
Post by: silnarm on 2 September 2009, 09:07:13
linux users just need to type 'jam' to compile.
If they are missing any deps, they can easily be found with their package manager, and will be installed where the build environment (Jam) will see them.

windows users don't generally have a compiler, even if they did Glest 3.2.2 does not come with any project files.
deps are not so easy to get, they have to be found individually, occasionally built from source, and the files put in the right place once obtained.

That said, I see no reason why PolitikerNEU should provide windows binaries, he after all is a linux user, and he too has no project files for windows.

Ps; nice hack :)
Title: Re: Glest with observers
Post by: assassin on 2 September 2009, 09:14:44
Yeah compiling on windows is harder, but not impossible  :-\
Title: Re: Glest with observers
Post by: ultifd on 16 March 2010, 03:05:37
Sorry, I know this is an OLD topic, but...  ::)
Since this would be helpful...   :)
Can anyone compile the files for Windows...  :bomb:  :thumbup:
thanks.  :O
Title: Re: Glest with observers
Post by: John.d.h on 17 March 2010, 08:00:00
I rarely ever read the multiplayer board, but I just happened to come across this topic, and I think it's a great idea.  Specifically, this could allow recordings of multiplayer battles and (other) fun tournament-related stuff.
Title: Re: Glest with observers
Post by: jda on 17 March 2010, 11:32:12
Could not get this to compile on Ubuntu Linux 9.10 Karmic Koala, 32 bit, neither with PolitikerNEU's nor with Platyhelmith's sources. :(

Here is the output of running jam (after ./configure of course) on Platyhelith's source:
Code: [Select]
...found 509 target(s)...
...using 44 temp target(s)...
...updating 22 target(s)...
C++ ./build/i686-pc-linux-gnu/optimize/shared_lib/sources/platform/posix/socket.o
shared_lib/sources/platform/posix/socket.cpp: In member function ‘void Shared::Platform::ClientSocket::connect(const Shared::Platform::Ip&, int)’:
shared_lib/sources/platform/posix/socket.cpp:228: error: ‘sprintf’ was not declared in this scope
shared_lib/sources/platform/posix/socket.cpp:229: error: ‘stderr’ was not declared in this scope
shared_lib/sources/platform/posix/socket.cpp:229: error: ‘fprintf’ was not declared in this scope

    g++ -c -o ./build/i686-pc-linux-gnu/optimize/shared_lib/sources/platform/posix/socket.o  -DPACKAGE_NAME="glest" -DPACKAGE_TARNAME="glest" -DPACKAGE_VERSION="3.1.2" -DPACKAGE_STRING="glest 3.1.2" -DPACKAGE_BUGREPORT="matze@braunis.de" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DUSE_POSIX_SOCKETS=/**/ -DX11_AVAILABLE=1 -DHAVE_GLOB_H=1 -DHAVE_SYS_IOCTL_H=1 -DUSE_SDL=/**/ -DHAVE_PTHREAD=1 -I. -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -pthread -pthread     -I/usr/include/lua5.1 -Ishared_lib/sources/../include/platform/sdl -Ishared_lib/sources/../include/platform/posix -Ishared_lib/sources/../include/util -Ishared_lib/sources/../include/graphics -Ishared_lib/sources/../include/graphics/gl -Ishared_lib/sources/../include/sound -Ishared_lib/sources/../include/sound/openal -Ishared_lib/sources/../include/xml -Ishared_lib/sources/../include/glew -Ishared_lib/sources/../include/lua   -O3 -DNDEBUG shared_lib/sources/platform/posix/socket.cpp

...failed C++ ./build/i686-pc-linux-gnu/optimize/shared_lib/sources/platform/posix/socket.o ...
...skipped libglestlib.a for lack of libglestlib.a(socket.o)...
C++ ./build/i686-pc-linux-gnu/optimize/glest_game/types/object_type.o
C++ ./build/i686-pc-linux-gnu/optimize/glest_game/types/command_type.o
C++ ./build/i686-pc-linux-gnu/optimize/glest_game/types/element_type.o
C++ ./build/i686-pc-linux-gnu/optimize/glest_game/types/unit_type.o
C++ ./build/i686-pc-linux-gnu/optimize/glest_game/world/time_flow.o
C++ ./build/i686-pc-linux-gnu/optimize/glest_game/world/tileset.o
C++ ./build/i686-pc-linux-gnu/optimize/glest_game/world/water_effects.o
C++ ./build/i686-pc-linux-gnu/optimize/glest_game/world/unit_updater.o
C++ ./build/i686-pc-linux-gnu/optimize/glest_game/world/surface_atlas.o
C++ ./build/i686-pc-linux-gnu/optimize/glest_game/world/minimap.o
C++ ./build/i686-pc-linux-gnu/optimize/glest_game/world/map.o
glest_game/world/map.cpp: In member function ‘void Glest::Game::Map::load(const std::string&, Glest::Game::TechTree*, Glest::Game::Tileset*)’:
glest_game/world/map.cpp:124: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result
glest_game/world/map.cpp:148: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result
glest_game/world/map.cpp:149: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result
glest_game/world/map.cpp:162: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result
glest_game/world/map.cpp:172: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result
glest_game/world/map.cpp:182: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result
C++ ./build/i686-pc-linux-gnu/optimize/glest_game/world/scenario.o
C++ ./build/i686-pc-linux-gnu/optimize/glest_game/world/world.o
...skipped glest for lack of libglestlib.a...
MkDir1 ./build/i686-pc-linux-gnu/optimize/glest_map_editor
C++ ./build/i686-pc-linux-gnu/optimize/glest_map_editor/renderer.o
C++ ./build/i686-pc-linux-gnu/optimize/glest_map_editor/map.o
glest_map_editor/map.cpp: In member function ‘void Glest::MapEditor::Map::loadFromFile(const std::string&)’:
glest_map_editor/map.cpp:413: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result
glest_map_editor/map.cpp:424: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result
glest_map_editor/map.cpp:425: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result
glest_map_editor/map.cpp:432: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result
glest_map_editor/map.cpp:439: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result
glest_map_editor/map.cpp:447: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’, declared with attribute warn_unused_result
C++ ./build/i686-pc-linux-gnu/optimize/glest_map_editor/program.o
C++ ./build/i686-pc-linux-gnu/optimize/glest_map_editor/main.o
...skipped glest_editor for lack of libglestlib.a...
...failed updating 1 target(s)...
...skipped 3 target(s)...
...updated 18 target(s)...
No executables are found afterwards. :(

Anyone got a clue?
Title: Re: Glest with observers
Post by: Yggdrasil on 17 March 2010, 12:54:30
Just add this to posix/socket.cpp, near top:
Code: [Select]
#include <cstdio>
The rest are warnings.
Title: Re: Glest with observers
Post by: jda on 18 March 2010, 00:30:01
Yep, worked like a charm. Thanks, Yggdrasil. :)
Title: Re: Glest with observers
Post by: jda on 26 March 2010, 17:16:31
Sorry for DPosting but I wanted to bring the attention back to this...

This is working perfectly ( Platyhelith's source ).
But... it is NOT in GAE.

Is it in Megaglest?It's not in Megaglest either.

This is a really useful feature, both for single/multi player teaching/learning as well a balancing tool (in the likes of the Spectators map Archmage did a while back ago, but honestly IMO, better).

I'd really like to see this implemented somewhere. ;)
It's also, AFAICT, completely unobstrusive of more recent/current developments. ;)

EDIT: I'd forgotten I had already looked for this in Megaglest. ;D
Title: Re: Glest with observers
Post by: PolitikerNEU on 26 March 2010, 17:43:29
Well _if_ this really doesn't interfere with recent changes you can try to apply the following patch:
Code: [Select]
[url=http://billhome.at/glest/myhacks.patch]http://billhome.at/glest/myhacks.patch[/url] (and fix the thing with stdio afterwards).

I'll try that for megaglest, will edit my post to say whether it succeeds or not.

The main problem is that the code quality is really bad - it was just a quick hack without any "strategy" behind it so there are no chances to include it permanently into megaglest and/or gae.

EDIT: No, it doesn't work. Sorry.
Title: Re: Glest with observers
Post by: jda on 26 March 2010, 18:04:14
Well _if_ this really doesn't interfere with recent changes
Erm, actually, I confess, I was talking out of my arse... ;D
What I meant to say was it does not interfere with current releases logic.
However, megaglest did add four more teams.
And gae, as of 0.2.13-beta1 sets FoW on or off in a per-match basis instead of the previous per-application-session one.
So you might run into some glitches there...?

Quote
you can try to apply the following patch:
Code: [Select]
[url=http://billhome.at/glest/myhacks.patch]http://billhome.at/glest/myhacks.patch[/url] (and fix the thing with stdio afterwards).
Right, maybe I'll try if I find some time. But if you couldn't get it to work... :(

Quote
I'll try that for megaglest, will edit my post to say whether it succeeds or not.
(...)
EDIT: No, it doesn't work. Sorry.
That's a shame. :( Still, I can still use the your original version for balancing purposes. So, your contribution is still very useful! ;)

Thanks. :)
Title: Re: Glest with observers
Post by: PolitikerNEU on 26 March 2010, 18:33:05
ok, I'll try to apply this patch "manually" to current megaglest. Maybe it gets ready today, maybe not.
Title: Re: Glest with observers
Post by: jda on 26 March 2010, 18:37:58
Sweet! ;D  :thumbup:
Title: Re: Glest with observers
Post by: PolitikerNEU on 26 March 2010, 20:48:24
So - i have manually applied the patch and made changes so at least glest is not crashing :-)

I can upload the patch to current megaglest svn and I'll upload the source folder, note that for this version of megaglest, you additionally need to have libpng and libjpeg; if you use Ubuntu 10.04 I could also give you a compiled binary if you want.

I'll edit my post when done.

Note that I "ported" only the observer-thing, not the simulanous keyboard/mouse-Movement things since the camera code changed a lot since I made this hack.

EDIT I: Patch to megaglest (Rev 159):
Code: [Select]
[url=http://billhome.at/glest/observer_hack_megaglest.patch]http://billhome.at/glest/observer_hack_megaglest.patch[/url]
EDIT II: Since the whole folder is too large, here is the patched source folder only:
Code: [Select]
http://billhome.at/glest/observer_hack_megaglest_source_159.zip
EDIT III: The patched glest binary (Ubuntu 10.04, 32bit)
Code: [Select]
[url=http://billhome.at/glest/glest.bin]http://billhome.at/glest/glest.bin[/url]
Title: Re: Glest with observers
Post by: ElimiNator on 26 March 2010, 21:33:42
Cool, I always wanted observers.  :)
Title: Re: Glest with observers
Post by: PolitikerNEU on 26 March 2010, 21:59:45
Well - there is still no windows version, so unfortunately you still can't use it :-) :-(
Title: Re: Glest with observers
Post by: ElimiNator on 27 March 2010, 03:28:09
I don't use windows , I have linux.  ;D
Title: Re: Glest with observers
Post by: jda on 27 March 2010, 03:56:41
So - i have manually applied the patch and made changes so at least glest is not crashing :-)

I can upload the patch to current megaglest svn and I'll upload the source folder, note that for this version of megaglest, you additionally need to have libpng and libjpeg; if you use Ubuntu 10.04 I could also give you a compiled binary if you want.

I'll edit my post when done.

Note that I "ported" only the observer-thing, not the simulanous keyboard/mouse-Movement things since the camera code changed a lot since I made this hack.

EDIT I: Patch to megaglest (Rev 155): http://billhome.at/glest/observer_hack_megaglest.patch (http://billhome.at/glest/observer_hack_megaglest.patch)

EDIT II: Since the whole folder is too large, here is the patched source folder only: http://billhome.at/glest/megaglest_obs_hack_source_155.zip (http://billhome.at/glest/megaglest_obs_hack_source_155.zip)

EDIT III: The patched glest binary (Ubuntu 10.04, 32bit) http://billhome.at/glest/glest.bin (http://billhome.at/glest/glest.bin)
Nice! :)
I'lln download and test the binaries on my Ubuntu 9.10 - should work unless the libraries used by glest/megaglest before have changed in a non backwards-compatible way; I would find it odd regarding Glest...  :| ).
If I can't get that to work, I'll try to build it from patched source then. ;)

Thank you! :)

EDIT: Well, the 10.04 binary works fine (kinda, see below) on my 32 bit 9.10. Everything functions perfectly but this small glitch/bug:
On the end-screen (the one with the victory/defeat and stats), regular megaglest (3.3.1) shows the stats for all 8 players (when playing 8 players of course) but your tweaked megaglest (3.3.2-dev) hides the stats for players 1, 7 and 8 (only 2 to 6 are displayed).
So... ingame it does work fine (either you play with or without observers) but the endgame stats are incomplete (also either way, with or without observers, the bug occurs always).
Note I have only tested with 8 players (this glitch may not occur when playing with less players, I didn't test that).

I'm still keeping it! ;D  8)
Title: Re: Glest with observers
Post by: PolitikerNEU on 27 March 2010, 08:04:24
Fixed the bug - actually the players were displayed, but off-screen :-)

But I'll need some time for uploading, switiching to current svn caused some conflicts. Hope version will get ready in about an hour or so, will edit my post then.

EDIT: Maybe more time since I can't compile svn version now

EDIT II: Silnarm helped me with compiling, works now:

Patch to megaglest (Rev 159): http://billhome.at/glest/observer_hack_megaglest.patch

Patched source folder (Rev 159) http://billhome.at/glest/observer_hack_megaglest_source_159.zip

The patched glest binary (Ubuntu 10.04, 32bit) http://billhome.at/glest/glest.bin
Title: Re: Glest with observers
Post by: jda on 27 March 2010, 11:06:41
Thanks, I'll try it later. :)  :thumbup:

EDIT: I tried it. The Observer functionality is gone!  :o :(
The v3.3.2-dev title you could see on the start menu of your previous patch also disappeared and the original v3.3.1 text appeared instead.

Was that last patch of yours (meant to be) aplied to the original megaglest or to the former patched megaglest?
It appears it was meant for your other patched megaglest but was aplied to the original 3.3.1 megaglest instead...?

Also... the official megaglest 3.3.2 is now out and, unfortunately does not contain this very nice feature. :(
Title: Re: Glest with observers
Post by: PolitikerNEU on 28 March 2010, 18:22:25
Ooops - seems I did something wrong.

Yeah, original megaglest will never contain this patch bec. it is written in a bad way.

I try to figure out the cause of the problem and upate my post ASAP.

EDIT: The patch always applies to unmodified megaglest svn.

I have updated the binary (changed) and the patch (stayed the same), and the source code: Code-URL is: http://billhome.at/glest/observer_hack_megaglest_source_167.zip (http://billhome.at/glest/observer_hack_megaglest_source_167.zip)

Note that I fixed a bug once: Team is per default = 1, you have to click once on "left" to make an observer, I don't know if this was fixed in the first megaglest-version I put here.

EDIT II: If I am able to edit posts, I am usually in IRC too: #glest on irc.freenode.net: URL is irc://irc.freenode.net/glest
It might be faster to sort out problems there.
Title: Re: Glest with observers
Post by: jda on 28 March 2010, 21:54:09
Thank you for the reply. :)

Sorry I missed you in the irc, you were already gone.

Anyway, I couldn't get it to work.
I copied your source code over the megaglest 3.3.1 source folder. and successfully compiled.

But when I run it, it just looks like regular 3.3.1, no Observers team.

Note that I fixed a bug once: Team is per default = 1, you have to click once on "left" to make an observer, I don't know if this was fixed in the first megaglest-version I put here.
The behaviour you describe (clicking "left" once when Team 1 is selected worked fine on your first binary (https://forum.megaglest.org/index.php?topic=4546.msg43763#msg43763). Now, after you corrected the end-game display, it just cycles back to Team 8.
And the worse thing is I saved your new version over the old one, so now I have no working version of your patch for megaglest. :(
Title: Re: Glest with observers
Post by: PolitikerNEU on 29 March 2010, 05:54:18
Have you tried to delete the source and then overwrite the source-folder with the one of the zip-file, then running jam distclean && sh autogen.sh && ./configure && jam (again)

I'll check if deleting source-folder + overwriting with my zip (note you need to decompress it in the glest-dir, not in the source-folder!) works for me, otherwise the binary has been updated to, so you might want to try it (again, compiled on 10.04/32 bit).

EDIT: I just noted that the source-folder structure of megaglest as you can download it from sourceforge is _completly different_ from the one svn uses. I'll try to provide a zip matching the source code structure of the megaglest as you can download it.

EDIT II: Here it is. I have tried extracting it over the downloadable megaglest-source and it worked there. I may be in IRC today, but don't know if I'll have time: http://billhome.at/glest/observer_hack_megaglest_str_166.zip
Title: Re: Glest with observers
Post by: jda on 29 March 2010, 10:23:20
SUCCESS! :)

Have you tried to delete the source and then overwrite the source-folder with the one of the zip-file, then running jam distclean && sh autogen.sh && ./configure && jam (again)
No, I hadn't tried that.
Also, I never did run autogen.sh before running configure (nor after nor any time). I did it now. Do you think that could be the reason it didn't work before (I didn't test, i.e. build without running autogen.sh first)?

Quote
I'll check if deleting source-folder + overwriting with my zip (note you need to decompress it in the glest-dir, not in the source-folder!) works for me, otherwise the binary has been updated to, so you might want to try it (again, compiled on 10.04/32 bit).
But I couldn't find the binary in your last post. Do you mean you updated the binary you link to on the post you did before that last one?

Quote
EDIT: I just noted that the source-folder structure of megaglest as you can download it from sourceforge is _completly different_ from the one svn uses. I'll try to provide a zip matching the source code structure of the megaglest as you can download it.

Quote
EDIT II: Here it is. I have tried extracting it over the downloadable megaglest-source and it worked there. I may be in IRC today, but don't know if I'll have time: http://billhome.at/glest/observer_hack_megaglest_str_166.zip
As I said in the begining of this post, that one worked just fine. :)
Also, I noticed the start menu now says it's v3.3.2-beta1 and I confirmed the "Rotate building when choosing its location" is working (which means it is indeed megaglest 3.3.2-beta1). AWESOME!  8)
However, the file you provide here is revision 166 whereas your previous link was r167. I'm unsure what's the most recent / best revision.  :-\

Thanks! :)  :thumbup:
Title: Re: Glest with observers
Post by: PolitikerNEU on 29 March 2010, 10:34:07
Yeah, I always update the binary/patch when I upload a new source code-zip.

Rev is 166 because I mistyped it, it is Rev 167 :-) - but the fixes wouldn't be really important bec. they affect windows only AFIR.

And yeah, running jam distclean and ./configure might be necessary because it might be that otherwise the glest binary can't be built because the links to libpng and libjpeg could be missing than - and some files might not be updated.
Title: Re: Glest with observers
Post by: jda on 29 March 2010, 10:42:57
And yeah, running jam distclean and ./configure might be necessary because it might be that otherwise the glest binary can't be built because the links to libpng and libjpeg could be missing than - and some files might not be updated.
Well, I had built the previous source on top of a clean megaglest 3.3.1 so no need to jam distclean - there would have been nothing to clean! ;D
What I did do differently this time was issuing autogen.sh before ./configure. ;)

Thamks. :)
Title: Re: Glest with observers
Post by: PolitikerNEU on 29 March 2010, 11:15:26
Yeah, and what you also had to do in the previous versions (as opposed to the last that worked) was to copy everything of the "source"-folder into the "root" folder where you make your source.
Title: Re: Glest with observers
Post by: jda on 29 March 2010, 12:38:03
True, that was also something I did wrong before, I had copied your folder into the <root>/source folder instead of directly to <root>. ;D

Thanks!