Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Thu Sep 02, 2010 6:05 pm

All times are UTC




Post new topic Reply to topic  [ 59 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: [Patch] Watch Other Companies GUI
PostPosted: Sun Sep 20, 2009 5:16 pm 
Engineer
Engineer
User avatar
Offline

Joined: Sun Oct 05, 2008 5:06 pm
Posts: 78
Location: Goulp, FR
Hello,

This patch has been designed to work on network games. It should help the server admin to watch other player building. It can been also used to follow a particular player in its building. It's based on last stable version 0.7.4

it's a console command. I dont know yet how it can be integrated to the GUI (button in the company window, or click in a company list window).

When activated, the map is scrolled where the company (any client) is building something

==========
Edit 07/10/2009 23:06

Here is new release with GUI.
It has been developped on the 0.7.3
There are 2 new files : watch_gui.h & watch_gui.cpp
source.list file has been updated, so project files can be rebuild with the generate(.vbs) script

the watching window is opened with "watch" console command (no parameter).

a new window can ben opened with the 16th button.

==========
Edit 08/10/2009 22:09

Watch Company Gui Release 2

  • zoom buttons resized
  • main window center button added
  • Title background colour sync to the company watched

==========
Edit 14/10/2009 20:22

Watch Company Gui Release 3

  • Added green bulb to indicate clients in the company
  • Added red bulb to indicate company activity

==========
Edit 13/12/2009 19:38

Watch Company Gui Release 4

  • Little update. Better code when geting the company name.

==========
Edit 28/12/2009 13:34

Watch Company Gui - Release 4

  • main files missing in the diff file

===========
Edit 24/01/2010 - 17:38 (GMT+1)

Watch Patch Gui - Release 5 - Based on r18867

  • using new widget system.
  • has client blot in orange for AIs
  • Add Menu "Watch Company" in the Map ToolBar Icon

===========
Edit 02/02/2010 - 08:03 (GMT+1)

Watch Company Patch - Release 6 - Based on r18972 / 1.0.0-b3

  • removed watch console command
  • update the OnClick function according r18966
  • scroll to the company.last_build_coordinate - Last place Build - when activating watching
  • watch the company being watched when opening new window from watching window
  • update some code for caption

===========
Edit 15/03/2010 - 22:09 (GMT+1)

Watch Company Patch - Release 6 - 1.0.0-RC2

===========
Edit 02/05/2010 - 15:20 (GMT+2)

Watch Company Patch - Release 7 - 1.0.1

  • Merge buttons has client and client activity

===========
Edit 25/06/2010 - 22:06 (GMT+2)

Watch Company Patch - Release 7 - 1.0.2

===========
Edit 06/08/2010 - 09:50 (GMT+2)

Watch Company Patch - Release 7 - 1.0.3


Attachments:
File comment: Watching Company Window release 3
watching_window_3.png
watching_window_3.png [ 12.96 KiB | Viewed 2586 times ]
File comment: Watch Company Patch v6 for r18972
watch_gui_6_r18972.diff [23.08 KiB]
Downloaded 29 times
File comment: Watch Company Patch v7 for 1.0.3
watch_gui_7_103.diff [23.37 KiB]
Downloaded 12 times

_________________
Pourquoi faire simple quand on peut faire compliqué ?
KISS - Keep It Simple, Stupid.
Open TTD Goulp Web Service
OpenTTD Goulp Web Forum


Last edited by Muxy on Fri Aug 06, 2010 7:52 am, edited 30 times in total.
Top
 Profile  
 
 Post subject: Re: Patch: Console Watch Command
PostPosted: Sun Sep 20, 2009 5:31 pm 
OpenTTD Developer
OpenTTD Developer
Offline

Joined: Thu Feb 09, 2006 7:15 pm
Posts: 3181
Based on the implementation you're looking at other companies. It could also work for AIs in single player.


Top
 Profile  
 
 Post subject: Re: Patch: Console Watch Command
PostPosted: Sun Sep 20, 2009 5:34 pm 
Engineer
Engineer
User avatar
Offline

Joined: Sun Oct 05, 2008 5:06 pm
Posts: 78
Location: Goulp, FR
Yeap,

but for the moment i use the ScrollMainWindowToTile function in the NetworkExecuteLocalCommandQueue function which is not used in single player. But in multi-player, it will also follow AIs.

For this to work in single player, i think the scroll has to be done at the end of the DoCommand...

_________________
Pourquoi faire simple quand on peut faire compliqué ?
KISS - Keep It Simple, Stupid.
Open TTD Goulp Web Service
OpenTTD Goulp Web Forum


Top
 Profile  
 
 Post subject: Re: Patch: Console Watch Command
PostPosted: Mon Sep 21, 2009 7:06 am 
President
President
Offline

Joined: Wed Feb 14, 2007 5:48 pm
Posts: 937
opening a viewport may be more interesting.... then one could also watch multiple companies

_________________
Image


Top
 Profile  
 
 Post subject: Re: Patch: Console Watch Command
PostPosted: Mon Sep 21, 2009 9:26 am 
Engineer
Engineer
User avatar
Offline

Joined: Sun Oct 05, 2008 5:06 pm
Posts: 78
Location: Goulp, FR
dihedral wrote:
opening a viewport may be more interesting.... then one could also watch multiple companies

Excellent !

Let me learn how viewport is functionning...

and for GUI, just a button in the company window "watch" opens the viewport, and when viewport is closed, watching stops.

_________________
Pourquoi faire simple quand on peut faire compliqué ?
KISS - Keep It Simple, Stupid.
Open TTD Goulp Web Service
OpenTTD Goulp Web Forum


Top
 Profile  
 
 Post subject: Re: Patch: Console Watch Command
PostPosted: Mon Sep 21, 2009 6:46 pm 
President
President
Offline

Joined: Wed Feb 14, 2007 5:48 pm
Posts: 937
might get a bit jumpy when 2 people are in one company and building like crazy!

_________________
Image


Top
 Profile  
 
 Post subject: Re: Patch: Console Watch Command
PostPosted: Sun Sep 27, 2009 2:24 pm 
Tycoon
Tycoon
User avatar
Offline

Joined: Sat Mar 06, 2004 11:51 pm
Posts: 1404
Location: The sunny side of Alps
dihedral wrote:
opening a viewport may be more interesting.... then one could also watch multiple companies

I have thought about this from time to time not in the form of a viewport but just "follow other company's viewing area" and it is nice to see the idea being discussed here.
I wish you success on this endeavour, Muxy. :wink:

_________________
NewGRF: Oil Wells in Temperate terrain now can Increase production, Better vehicle names.
Patches (OpenTTD): Improved smooth_economy [in trunk], More (diesel) smoke [in trunk], Realistic_acceleration finetune.

Keep 'em rollin'!


Top
 Profile  
 
 Post subject: Re: Patch: Console Watch Command
PostPosted: Sun Sep 27, 2009 2:59 pm 
Tycoon
Tycoon
User avatar
Offline

Joined: Sat Aug 25, 2007 5:03 pm
Posts: 2076
Location: ~/
Planetmaker had a patch like this once I think.

_________________

Benny's OpenTTD installer - As easy as it gets. | My old avatar is baaaaack.

Image


Top
 Profile E-mail  
 
 Post subject: Re: Patch: Console Watch Command
PostPosted: Sun Sep 27, 2009 3:00 pm 
Tycoon
Tycoon
User avatar
Offline

Joined: Sat Aug 25, 2007 5:03 pm
Posts: 2076
Location: ~/
dihedral wrote:
might get a bit jumpy when 2 people are in one company and building like crazy!

Or in an OTTDcoop game.

_________________

Benny's OpenTTD installer - As easy as it gets. | My old avatar is baaaaack.

Image


Top
 Profile E-mail  
 
 Post subject: Re: Patch: Console Watch Command
PostPosted: Mon Sep 28, 2009 8:29 am 
President
President
Offline

Joined: Wed Feb 14, 2007 5:48 pm
Posts: 937
then it might be better to also transmit the client id, and watch clients instead of companies!

_________________
Image


Top
 Profile  
 
 Post subject: Re: Patch: Console Watch Command
PostPosted: Mon Sep 28, 2009 7:40 pm 
Tycoon
Tycoon
Offline

Joined: Thu Apr 02, 2009 10:43 pm
Posts: 3004
Location: Massachusetts, USA
Really great patch, which could be used for servers, making enforcing the rules easy!
I would seriously reconsider the wording for some of the command help, etc. (Yes, I can tell English isn't your mother tongue), Like so:
Attachment:
File comment: Revised Language, Tested and working
watch_cmd_072_revised.patch [3.77 KiB]
Downloaded 50 times


Binary:


Attachments:
File comment: Binary for revised language
watch_cmd_072_revised.zip [3.95 MiB]
Downloaded 23 times

_________________
Image
SimulationNation Servers - Channel #sn on OFTC (irc.oftc.net)


Last edited by petert on Sun Oct 04, 2009 9:59 pm, edited 2 times in total.
Top
 Profile  
 
 Post subject: Re: Patch: Console Watch Command
PostPosted: Wed Sep 30, 2009 7:51 pm 
Engineer
Engineer
User avatar
Offline

Joined: Sun Oct 05, 2008 5:06 pm
Posts: 78
Location: Goulp, FR
petert wrote:
Really great patch, which could be used for servers, making enforcing the rules easy!
I would seriously reconsider the wording for some of the command help, etc. (Yes, I can tell English isn't your mother tongue)

Thanks for your comments & new translation. I'm just a frenchie guy who tries :?:

About the patch, i'm currently learning how the windowing system works and will produce a new release with a window on which you can choose the company to watch, and of course, open a new watching window.

stay tunned...

_________________
Pourquoi faire simple quand on peut faire compliqué ?
KISS - Keep It Simple, Stupid.
Open TTD Goulp Web Service
OpenTTD Goulp Web Forum


Top
 Profile  
 
 Post subject: Re: Patch: Console Watch Command
PostPosted: Thu Oct 01, 2009 8:45 pm 
Tycoon
Tycoon
Offline

Joined: Thu Apr 02, 2009 10:43 pm
Posts: 3004
Location: Massachusetts, USA
You're very welcome, this is such a great tool, I hope it makes trunk. You should post on bugs.openttd.org as a patch.

_________________
Image
SimulationNation Servers - Channel #sn on OFTC (irc.oftc.net)


Top
 Profile  
 
 Post subject: Re: Patch: Console Watch Command
PostPosted: Thu Oct 01, 2009 9:07 pm 
OpenTTD Developer
OpenTTD Developer
Offline

Joined: Tue Oct 03, 2006 6:26 pm
Posts: 318
Location: Prague, Czech Republic
I had a patch similiar to this one... Updated to current rev, maybe it will be helpful for you :) (maybe won't...) Hope it still works.


Attachments:
center_player_r17680.diff [7.48 KiB]
Downloaded 32 times

_________________
Image
Top
 Profile  
 
 Post subject: Re: Patch: Console Watch Command
PostPosted: Sat Oct 03, 2009 7:04 pm 
Tycoon
Tycoon
User avatar
Offline

Joined: Wed Jun 06, 2007 9:07 pm
Posts: 1697
Location: Czech Republic
SirkoZ wrote:
but just "follow other company's viewing area" and it is nice to see the idea being discussed here.


This is not possible - since when you just move viewport around, nothing is sent to server, only when you actually build something (and you can also use extra viewport windows to build things :). And AI's even don't have anything like viewport at all.

Best you can do is center while something is built. Perhaps make it slightly configurable, like no re-centering if another thing built is still near centre of the viewport to reduce jumping.

_________________
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)


Top
 Profile  
 
 Post subject: Re: Patch: Console Watch Command
PostPosted: Sun Oct 04, 2009 10:14 pm 
Tycoon
Tycoon
Offline

Joined: Thu Apr 02, 2009 10:43 pm
Posts: 3004
Location: Massachusetts, USA
Updated to 0.7.3:
Attachment:
watch_cmd_073_revised.patch [3.77 KiB]
Downloaded 20 times


Binary:
Attachment:
watch_cmd_073_revised.zip [3.96 MiB]
Downloaded 23 times

_________________
Image
SimulationNation Servers - Channel #sn on OFTC (irc.oftc.net)


Top
 Profile  
 
 Post subject: Re: Patch: Console Watch Command
PostPosted: Tue Oct 06, 2009 1:56 pm 
Tycoon
Tycoon
User avatar
Offline

Joined: Wed Jun 06, 2007 9:07 pm
Posts: 1697
Location: Czech Republic
I added the patch to my patchpack and when testing it, it seems that there is some bug - when I joined a server where I was alone, it seems that by default I am watched. When I tried "watch 0" to turn watching off, it said:
Unknown player. Player range is between 1 and 15. Use 0 to cancel watching

I think the problem arises from "uint8 _watched_player" -> the variable is unsigned 8bit int, therefore it is always >=0, therefore you are always watching someone.

When you compare the index (CompanyID is enum and basically it is also unsigned int) to -1 (in the condition to turn off the watching), it will always be false, since if you specify "watch 0", the index will probably have something like 255 at that point. So you can't turn the watching off ...

Also, by default you should not be watching anyone.

_________________
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)


Top
 Profile  
 
 Post subject: Re: Patch: Console Watch Command
PostPosted: Tue Oct 06, 2009 9:14 pm 
Tycoon
Tycoon
User avatar
Offline

Joined: Wed Jun 06, 2007 9:07 pm
Posts: 1697
Location: Czech Republic
Ok, I am attaching the patch with these problems fixed. By default you don't watch anyone and watching can be stopped.


Attachments:
File comment: Working version for 0.7.3
watch_cmd_073_working.patch [3.13 KiB]
Downloaded 22 times

_________________
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
Top
 Profile  
 
 Post subject: Re: Patch: Console Watch Command
PostPosted: Tue Oct 06, 2009 11:36 pm 
Engineer
Engineer
User avatar
Offline

Joined: Sun Oct 05, 2008 5:06 pm
Posts: 78
Location: Goulp, FR
Okay...

I have a little link problem. I ehance this patch with a window with a button per company... so i defined a WatchCompany window derived from window and all painting stuff. Also i defined a void OnDoCommand( CompanyId, TileInex ) function in the public section. And in the DoCommandP, after getting each WatchCompany window, i just call the OnDoCommand() like this : wc->OnDoCommand( ) with the rigth parameters, and the linker tells me a story about the fact he cant link my stuff...

WatchCompany window definition
Code:
struct WatchCompany : public Window
{
public:
   CompanyID watched_company;

   WatchCompany(const WindowDesc *desc, int window_number, CompanyID company_to_watch );

   virtual void OnPaint();
   virtual void OnTimeout();
   virtual void OnClick(Point pt, int widget);
   virtual void OnResize(Point new_size, Point delta);
   virtual void OnScroll(Point delta);
   virtual void OnMouseWheel(int wheel);
   virtual void OnInvalidateData(int data = 0);
   void OnDoCommand( CompanyByte company, TileIndex tile );
};


From DoCommandP in comand.cpp
Code:
int watching_window = 0;
WatchCompany *wc;
wc = dynamic_cast<WatchCompany*>(FindWindowById(WC_WATCH_COMPANY, watching_window));
while ( wc != NULL) {
   wc->OnDoCommand( _current_company, tile );
   watching_window++;
   wc = dynamic_cast<WatchCompany*>(FindWindowById(WC_WATCH_COMPANY, watching_window));
}


Here is the linker story
Code:
command.obj : error LNK2019: symbole externe non résolu
"public: void __thiscall WatchCompany::OnDoCommand(struct TinyEnumT<enum Owner>,unsigned int)"
(?OnDoCommand@WatchCompany@@QAEXU?$TinyEnumT@W4Owner@@@@I@Z) référencé dans la fonction
"bool __fastcall DoCommandP(unsigned int,unsigned int,unsigned int,unsigned int,
        void (__fastcall*)(bool,unsigned int,unsigned int,unsigned int),char const *,bool)"
(?DoCommandP@@YI_NIIIIP6IX_NIII@ZPBD0@Z)


Of course, the void OnDoCommand( ) has a definition and some code !
like this
Code:
   void OnDoCommand( CompanyByte company, TileIndex tile )
   {
      if (watched_company == company)
      {
         // Scroll window to the tile
      }
   }



May be it's late...

Any idea ?


Attachments:
watching_window.png
watching_window.png [ 6.15 KiB | Viewed 2759 times ]

_________________
Pourquoi faire simple quand on peut faire compliqué ?
KISS - Keep It Simple, Stupid.
Open TTD Goulp Web Service
OpenTTD Goulp Web Forum


Last edited by Muxy on Tue Oct 06, 2009 11:42 pm, edited 1 time in total.
Top
 Profile  
 
 Post subject: Re: Patch: Console Watch Command
PostPosted: Tue Oct 06, 2009 11:42 pm 
OpenTTD Developer
OpenTTD Developer
Offline

Joined: Thu Dec 20, 2007 12:49 pm
Posts: 2412
_current_company is a CompanyID, not a CompanyByte.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 59 posts ]  Go to page 1, 2, 3  Next

All times are UTC


Who is online

Users browsing this forum: Google Adsense [Bot], muzzy and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Sydney web site design | Breast Enlargement | Breast Enlargement | Malaysian Property | Breast Enlargement
Powered by phpBB © 2000-2009 phpBB Group

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2010.
Hosted by Zernebok.