URL:
  <http://gna.org/bugs/?13515>

                 Summary: [Patch] Improved voting code from warclient
                 Project: Freeciv
            Submitted by: mbook
            Submitted on: Wednesday 05/13/2009 at 02:43
                Category: general
                Severity: 3 - Normal
                Priority: 5 - Normal
                  Status: Ready For Test
             Assigned to: mbook
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 
        Operating System: None

    _______________________________________________________

Details:

Attached patches for S2_1 and trunk port the base
functionality of the improved voting code present
in the latest versions of warclient.

These patches consist of packet definitions for 
vote information and the basic client and server
handling infrastructure. What is not included is
the client voting gui (the "votebar" in warclient)
which will be posted later. Also some dubious,
experimental, or not quite useful warclient
features were omitted (e.g. the "hacks" necessary
for the /poll command, obscure vote flags, per
setting vote parameters, etc.; these are all
fairly simple and their inclusion can be reeval-
uated should the need arise later).


5 new packets are added:
  PACKET_VOTE_NEW=145;sc
  PACKET_VOTE_UPDATE=146;sc
  PACKET_VOTE_REMOVE=147;sc
  PACKET_VOTE_RESOLVE=148;sc
  PACKET_VOTE_SUBMIT=149;cs   <-- client to server

For S2_1 the packets depend on the optional
"voteinfo" capability; the server does not send
the packets if the client does not have this
capability. This ensures network compatibility
with older 2.1 versions (they still see all
relevant voting text messages and can use all
voting server commands as before).


4 new source files are added to S2_1:
  server/voting.[ch]
  client/voteinfo.[ch]

In trunk the server-side files are already present.
Though the trunk version of this patch reverts
some improvements I had previously made to trunk
regarding the voting code, I decided that this
temporary setback outways the advantage gained
from synchronizing (more or less) the two branches.
This way improvement patches for both branches
will be written more easily (e.g. using the generic
iterator interface for iterating votes in stdinhand
instead of relying on the global vote_list variable).

The code in the client-side voteinfo files is used
to represent the currently running votes known to
the client as a set of elements in a queue. When
the server creates a new vote, it tells the client
via a packet and the client then adds a new record
to the end of the queue. When the server removes
a vote, it similarly sends a remove request to the
client and corresponding vote is removed from the
queue. The "head" of the queue would be the vote
that is currently visible to the user. There are
also other aspects of the module that will really
only make sense once the gui code is added (e.g.
vote records can be removed after a short delay,
the queue can be cycled, etc.).

The gui function voteinfo_gui_update() is added as
a stub to all client guis; this will be used for
refreshing the gui interface when it is in place.


Lastly some small related adjustments are made:
- Added vote flags and percent to all command
  definitions.
- Added convenience function command_access_level()
  (S2_1 only).
- Added command accessors for vote parameters
  (trunk only).
- Made notify_team send to all players if the
  player argument is NULL (this is used to make
  all-player votes a special case of team votes -
  "team votes" themselves can later be useful for
  example for the /surrender command).
- Some cleanup and reformatting of vote_command()
  and handle_stdin_input() in stdinhand.c.


I apologize for the fairly large patch; I will
test it more myself, and any feedback will be
appreciated. The code itself should be quite
solid, having been running on warclient servers
for the past year or so without problems; any
bugs will surely be due to mistakes in my
adaptation of it. ;)


----------------------------------------------------------------
アリが壁を這っている。戦争の始まりだ。



    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Wednesday 05/13/2009 at 02:43  Name: S2_1-voting.patch  Size: 87kB  
By: mbook

<http://gna.org/bugs/download.php?file_id=5775>
-------------------------------------------------------
Date: Wednesday 05/13/2009 at 02:43  Name: trunk-voting.patch  Size: 90kB  
By: mbook

<http://gna.org/bugs/download.php?file_id=5776>

    _______________________________________________________

Reply to this item at:

  <http://gna.org/bugs/?13515>

_______________________________________________
  Message sent via/by Gna!
  http://gna.org/


_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to