May 19, 2024, 09:16:28 pm

The Gang Garrison 2 Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

NOTICE: Wondering where all the forums have gone?

Join the community Discord server!

Pages: 1 ... 32 33 [34] 35 36 ... 77

Author Topic: Official PyGG2 Development thread  (Read 143004 times)

Nukleus

  • Guest
Re: Porting GG2 to Python - PyGG2
« Reply #495 on: February 01, 2012, 12:39:34 am »

The guide worked 100% perfectly on Windows 7.
Logged

Orpheon

  • Moderator
  • *****
  • Karma: 15
  • Offline Offline
  • Posts: 6409
  • Developer
Re: Porting GG2 to Python - PyGG2
« Reply #496 on: February 04, 2012, 08:44:02 am »

Should the client try to guess spawning and dieing, or should it not do anything about them without the server telling him to do so?

On one side, the cases where they'll disagree and it's going to be noticeable are extremely rare, and the client should be able to extrapolate as much as possible, but on the other hand, when they DO disagree it looks shitty.

In both cases, this is only something that'll appear with a pretty big latency.

Opinions?
Logged

Lorgan

  • Retired Randomizer Mod Developer
  • Resident Miku
  • *****
  • Karma: 28
  • Offline Offline
  • Posts: 3625
    • My own website
Re: Porting GG2 to Python - PyGG2
« Reply #497 on: February 04, 2012, 09:04:22 am »

I see no reason to do that, i can only see this doing weird things.
Logged
Unfortunately, turning a section into a communist oppressive regime is not against the forum rules, so there is really nothing we can do.
Quote from: steam
21:08 - Hullusorsa: lorgan, when will you buy us the keys?
21:09 - Lorgan: i'm waiting for greece to collapse so the value of the euro drops
21:09 - Lorgan: not even joking

MedO

  • Owns this place
  • *****
  • Karma: 151
  • Offline Offline
  • Posts: 1752
Re: Porting GG2 to Python - PyGG2
« Reply #498 on: February 04, 2012, 09:49:36 am »

imo death should not be predicted, it could be quite confusing to die, rage and then notice you are not dead at all. Also causes programming issues, like aborting the killcam (or only starting it once death is confirmed).
Logged
Quote from: Alfred North Whitehead
It is the business of the future to be dangerous; and it is among the merits of science that it equips the future for its duties.

Quote from: John Carmack
[...] if you have a large enough codebase, any class of error that is syntactically legal probably exists there.

Orpheon

  • Moderator
  • *****
  • Karma: 15
  • Offline Offline
  • Posts: 6409
  • Developer
Re: Porting GG2 to Python - PyGG2
« Reply #499 on: February 04, 2012, 10:16:27 am »

Ok.

Alright, I set up the bare-bones of server networking. It works, as in doesn't error out when you run it, but it's still lacking the FULL_UPDATE and any kind of handling of joining players.
Right now, I'm working on getting the client up to date with it, and maybe (with a lot of luck) we'll have a shared world by the end of this week.

If anyone wants to poke around the code to spot glaring problems, please do. There's one problem I'm aware of, and it's in networking/event.py:
Code: [Select]
@clientevent
class Client_Event_Inputstate(object):
    eventid = constants.INPUTSTATE

    def __init__(self, bytestr):
        self.bytestr = bytestr

    def pack(self):
        packetstr += struct.pack(">H", len(self.bytestr)) # TODO: Implement a better system that doesn't require this length, because it shouldn't be needed.
        packetstr += bytestr

        return packetstr

    def unpack(self, packetstr):
        length = struct.unpack_from(">H", packetstr)
        bytestr = packetstr[:length]

        return struct.calcsize(">H")+length
Notice the TODO. I can't imagine a good system that stays clean and compatible with the rest (this shouldn't pack or unpack it, since that requires access on the game engine, which it shouldn't have, but without it it can't know the length of the event either), but this is a hacky fix.
Any ideas are welcome.


Also, a small design question: Is it ok if I make the Full update just have that information that the snapshot update doesn't, and rely on the fact that it'll never get sent without?
EDIT: Dammit, the system doesn't allow for this, because then knowing when to move SNAPSHOT_UPDATE to the back and when to leave it at the front would get complicated.
I'm just going to make the FULL_UPDATE handler call the SNAPSHOT_UPDATE one, and leave it at that.
« Last Edit: February 04, 2012, 10:49:52 am by Orpheon »
Logged

Orpheon

  • Moderator
  • *****
  • Karma: 15
  • Offline Offline
  • Posts: 6409
  • Developer
Re: Official PyGG2 Development thread
« Reply #500 on: February 04, 2012, 02:39:28 pm »

I need help for a non-hacky way to re-arrange the packet.

We decided to compress the packet with XOR adding and then run-length compression on the last ACKed packet. Since this works better with lots of overlap, we decided to put the state data first in the packet, to get as much overlap as possible (events have a varying length, which isn't good).

My problem is that I'm searching for a clean way to do this:
Code: (networking/packet.py) [Select]
       while packetstr:
            eventid = struct.unpack_from(">B", packetstr)
            packetstr = packetstr[struct.calcsize(">B"):]

            if self.sender == "client":
                packet_event = object.__new__(event.clientevents[eventid])
            else:
                packet_event = object.__new__(event.serverevents[eventid])

            eventsize = packet_event.unpack(packetstr)
            packetstr = packetstr[eventsize:]

            self.events.append(packet_event)
Code: (server/networker.py) [Select]
           try:
                packet.unpack(data)
            except:
                # parse error, don't throw exception but print it
                print("Parse error: %s" % sys.exc_info()[1])
                continue # drop packet

            # only handle this packet if we know the player
            if sender in self.players:
                for event in packet.events:
                    event_handler.eventhandlers[type(event)](self, game, self.players[sender], event)

Somewhere between that, the events that handle of states have to get pushed to the end. Is there any easy built-in or implicit way to do this, or do I have to use a while loop like this:
Code: [Select]
i=0
while i < len(events):
    if event_is_state:
        event = events.pop(i)
        events.append(event)
        i -= 1
    i += 1
which won't even work like that because of the end, but yeah.

Also, I'm not sure I can guarantee that there won't be more than two state events in the same packet. It depends on how we manage them.
« Last Edit: February 04, 2012, 02:40:34 pm by Orpheon »
Logged

.

  • Junior Member
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 75
Re: Official PyGG2 Development thread
« Reply #501 on: February 04, 2012, 03:15:07 pm »

When are you guys going to release this as the official GG2 mod? As 2.5, 2.6, 2.7?
Logged

Dusty

  • 2012 Haxxy Award Winner
  • *
  • Karma: -78
  • Offline Offline
  • Posts: 10312
  • Dust in a box under a table
Re: Official PyGG2 Development thread
« Reply #502 on: February 04, 2012, 06:09:54 pm »

when it's done.

Orpheon

  • Moderator
  • *****
  • Karma: 15
  • Offline Offline
  • Posts: 6409
  • Developer
Re: Official PyGG2 Development thread
« Reply #503 on: February 08, 2012, 02:09:21 pm »

Ok, I'm retracting my promise of a working shared world this week. I'm not going to make it.

After lots and lots of debugging (this is only the result, not the many in-between steps), I just noticed that the ack sytem still has a huge hole, and that the client code isn't really ready for this at all.

I did manage to get the client say it's there, and the server answer "Welcome, and this is how the game looks like". That's as far as I got.

There's still loads of work to be done, and I'm starting to fear for the overall stability of the whole thing. There are some things that just smell hacky, even to me, and although I can't think of any alternative it's still not a good thing.


Also, you guys could/should really read and try to understand the network code. I'm basically making it alone here, and I make mistakes, so I'd be happy if someone else is looking at what I'm doing so that my mistakes don't get noticed a week later.
Note: With network code, I mean everything in "networking/*", "server/networker.py", "server/event_handler.py", "server/player.py" "client/networker.py", "client/event_handler.py", and the de/serialize methods in the engine.
Logged

NAGN

  • Developer
  • ******
  • Karma: 146
  • Offline Offline
  • Posts: 16150
  • Yeah so now I have an idea
Re: Official PyGG2 Development thread
« Reply #504 on: February 09, 2012, 05:32:13 pm »

how do I open the files in a file explorer in komodo edit
Logged

Orpheon

  • Moderator
  • *****
  • Karma: 15
  • Offline Offline
  • Posts: 6409
  • Developer
Re: Official PyGG2 Development thread
« Reply #505 on: February 10, 2012, 11:33:02 am »

how do I open the files in a file explorer in komodo edit
1. Open komodo edit.
2. On the left column, go search your folder, right-click on it and press "Make this folder root".
3. Open files by double-clicking on them there.
« Last Edit: February 10, 2012, 11:34:00 am by Orpheon »
Logged

Orpheon

  • Moderator
  • *****
  • Karma: 15
  • Offline Offline
  • Posts: 6409
  • Developer
Re: Official PyGG2 Development thread
« Reply #506 on: February 13, 2012, 11:51:07 am »



This is a client connected to a server.  :woot:

Most of the networking core is now done and working. There are still some small bugs, and lots of stuff aren't coded (like teams or map modes), but the underlying packet and event management is done.

For the interested, stuff is still at the Networking branch, haven't pulled it in yet.


PS: Multi-clienting won't work, because of a architecture decision. Don't be surprised if it doesn't work for you, it shouldn't.
« Last Edit: February 13, 2012, 12:50:48 pm by Orpheon »
Logged

AcidLead

  • The Flash of the Action
  • Veteran Beta Tester
  • *****
  • Karma: 103
  • Offline Offline
  • Posts: 6370
  • Our hero returns triumphant. Execute him at once.
Re: Official PyGG2 Development thread
« Reply #507 on: February 13, 2012, 12:16:31 pm »

:D

Probably unecessary but eh.
Logged
fire at cyberdisc
eighty-five percent hit chance
doh, she missed the shot

Phantom Brave

  • All Hail Classicwell
  • Moderator
  • *****
  • Karma: 70
  • Offline Offline
  • Posts: 12532
  • Another one --
Re: Official PyGG2 Development thread
« Reply #508 on: February 13, 2012, 12:38:05 pm »

multiclienting not working is a pretty big deal. What was worth sacrificing it for?
« Last Edit: February 13, 2012, 12:38:20 pm by Rainy »
Logged

http://steamcommunity.com/id/wareya/
ladies and gentlemen i would like to announce that the fact of the matter is up that the fact of the matter is a fact and it matters

Orpheon

  • Moderator
  • *****
  • Karma: 15
  • Offline Offline
  • Posts: 6409
  • Developer
Re: Official PyGG2 Development thread
« Reply #509 on: February 13, 2012, 12:58:45 pm »

multiclienting not working is a pretty big deal. What was worth sacrificing it for?
It's probably possible to make it work. And it was for making a distinction between a joining player joining and a packet sent by a former joining player that took a long travel.
Actually, by using ports as identification as well as ip, it should be possible.

Also, I put a print statement in the current server engine (with a client inside and shooting), to print the fps.
50'000 fps.
50'000 FPS!!!!
 :panic:
Logged
Pages: 1 ... 32 33 [34] 35 36 ... 77
 

Page created in 0.034 seconds with 47 queries.