Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Server cleanup #36

Merged
merged 16 commits into from

2 participants

@crazy2be
Owner

I rewrote/restructured a bunch of the server to prepare for doing simulations on the server.

Things included in this diff:

  • Player has been renamed to Client- once we have simulation on the server, we will want to deal with Players in said simulation. Clients better describe what they are anyway.
  • The message processing layer on the server-side has been totally redone. The old solution had no static typing at all, and was basically just a bunch of type assertions all over the place (standard in JavaScript, but we can do better in go!).
    • As part of the changes to message handling, all message fields have been changed to uppercase, and many of the internal structs have also been changed to uppercase. This looks kinda ugly now (doing .X, ,Y, ,Z), but I'm sure we'll get used to it. It makes the code much cleaner (no need to manually convert to JSON or have struct tags).
    • We should probably change the messages JavaScript sends to go in order to reflect this convention, but I haven't done it yet.

Those two changes account for the majority of the diff.

Oh, and I added client-side hitboxes and shot detection, but it's not really useful until we have it on the server (which is why all this cleanup happened).

I'm sending this pull request now, because this accounts for the most major changes to the server which will affect chat, and the changes are reasonable stable, so why not (+reduce our branch count by one!)

Sorry for the messy diff. A lot happened, some of these changes are from last week. I'll try to keep the diffs smaller and cleaner in the future.

Comments/concerns/suggestions?

@crazy2be crazy2be commented on the diff
client/js/entities/entity.js
((7 lines not shown))
var material = new THREE.MeshBasicMaterial({
color: 0x0000ff,
wireframe: true,
});
+ var hitboxMaterial = new THREE.MeshBasicMaterial({
@crazy2be Owner

We should eventually make this enabled with a flag or something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@kieve kieve merged commit 8dbf38a into master
@crazy2be crazy2be commented on the diff
client/js/inventory.js
@@ -9,8 +9,13 @@ function WeaponInventory(world, camera) {
var actions = [
function () {
- var intersect = world.findTargetIntersection(camera);
- if (intersect) world.addSmallCube(intersect.point);
+ var intersect = world.findPlayerIntersection(camera);
+ if (intersect) {
+ console.log("Hit!!", intersect, intersect.item);
@crazy2be Owner

This lets you hit players (client side detection only obviously)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@crazy2be crazy2be commented on the diff
server/client.go
@@ -0,0 +1,154 @@
+package main
@crazy2be Owner

This file is basically just what player.go used to be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@crazy2be crazy2be commented on the diff
server/client.go
((98 lines not shown))
+func (c *Client) handleClientPosition(m *MsgPlayerPosition) {
+ wc := m.Pos
+
+ positionBroadcast := &MsgEntityPosition{
+ Pos: m.Pos,
+ Rot: m.Rot,
+ ID: c.name,
+ }
+ c.world.Broadcast <- positionBroadcast
+// playerState := &PlayerState{
+// Position: wc,
+// Rotation: readVec3(pl["rot"].(map[string]interface{})),
+// Controls: readControlState(pl["controls"].(map[string]interface{})),
+// Name: c.name,
+// }
+// c.world.StateUpdate <- playerState
@crazy2be Owner

Sign of things to come :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@crazy2be crazy2be commented on the diff
server/conn.go
((46 lines not shown))
return m
}
+
+func kindToType(kind MessageKind) Message {
@crazy2be Owner

I wish there was a cleaner way to do this, but I couldn't figure one out. In anycase, it's much better than it was before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@crazy2be crazy2be commented on the diff
server/coords.go
((61 lines not shown))
}
}
-func (wc WorldCoords) toMap() map[string]interface{} {
@crazy2be Owner

Glad to see these things go! :dancers:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@crazy2be crazy2be deleted the server-cleanup branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 24, 2013
  1. Made all player position data relative to center of player, rather th…

    authored
    …an camera position. Added back player models (but left hitboxes still)
  2. Rename Player to Client.

    authored
  3. Forgot to add client.go.

    authored
  4. Cleanup server code.

    authored
Commits on Mar 25, 2013
Something went wrong with that request. Please try again.