From: <Min...@t-...> - 2002-09-17 10:12:06
|
Ok, I write down some network packages as a reference. This is the new design proposal. ---------------- Opening backpack ---------------- How it works: ------------- The client will never get information about objects that are inside other objects like backpacks, unless he asks for it with this message. This message is not needed for special purpose slots like armor, weapon, shield, as those will be auto transmitted by the server on object transfer during perceptions. Client2Server::Package type: 1 (=opening container) ------------------------ Sint32 package type (=1) Object::ID playerID Object::ID container ID ------------------------ Server2Client::Package type: 1 (=opening container) ------------------------- Sint32 package type (=1) list<Object> all childrens, even nested ones ------------------------- ------------ Tradewindow ------------ How it works: ------------- This message is a client2client message. The server relays it and does the appropriate actions that the player asks him to. It only consists of 5 integers right now, so its actually really small. (which is a good thing) Client2Client::Package type 2 (=tradewindow) --------------------------- Sint32 package type (=2) Sint32 command (= enum (REQUEST, ACCEPT, PUT, REMOVE, LOCK, UNLOCK, FINISH, CANCEL)) Object::ID source player Object::ID target player Object::ID object that is moved --------------------------- Example ------- (I will use the enum names instead of integers to make it readable. The first integer I leave out, its always 2 for package type) Situation: PlayerID 1 trades with PlayerID 2, both put in two objects, then remove one. C1 -> C2: REQUEST 1 2 -1 (object is not used here, so last one is Object::Invalid) C2 -> C1: ACCEPT 2 1 -1 Handshake complete, both tradewindows open. C1 -> C2: PUT 1 2 666 The object 666 is put into the tradewindow, the server will move the object physically from the players backpack or wherever it was into the players tradebox. (Which is a special slot on every player, called tradebox. Its similar to the bankbox.) Note that the object is still slotted on the player, inside the tradebox of course. C2 -> C1: PUT 2 1 888 C2 wants to trade his object 888 against the 666 of C1, so he puts it in. C1 doesnt like it, he wants something else. C2 puts it in as well: C2 -> C1: PUT 2 1 777 C1 still doesnt like it. He puts in something else (444) and removes his valuable object 666: C1 -> C2: PUT 1 2 444 C1 -> C2: REMOVE 1 2 666 C2 wants that, but think 777 is too valuable, so he removes it: C2 -> C1: REMOVE 2 1 777 Now both players agree... C1 trades 444 against C2s 888. They both lock their boxes: C2 -> C1: LOCK 2 1 -1 C1 -> C2: LOCK 1 2 -1 As soon as one box is locked, nobody can use either PUT or REMOVE anymore. The only allowable commands after that are LOCK, CANCEL, FINISH or UNLOCK. But both agree, so they confirm it: C1 -> C2: FINISH 1 2 -1 C2 -> C1: FINISH 2 1 -1 What happens now is that the server just exchanges the IDs of the tradeboxes, meaning C1 will get C2s tradebox and vice versa. (The whole object with all children attached, and of course the parents will be exchanged.) SkyFlash |