Skip to content

Commit

Permalink
Resolved and ready for merge!
Browse files Browse the repository at this point in the history
  • Loading branch information
kharidiron committed Feb 11, 2015
2 parents 145a7d6 + f5e3fae commit f020179
Show file tree
Hide file tree
Showing 37 changed files with 1,090 additions and 428 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ nosetests.xml
.pydevproject

# Project specific
*config.json
*.json
*.db
*.db-journal
*.log
*.log.*
.idea/
bookmarks/

# Vim mess cleanup
*.swp
*.un~
.ropeproject/
4 changes: 4 additions & 0 deletions .landscape.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
doc-warnings: yes
test-warnings: no
strictness: high
autodetect: yes
36 changes: 30 additions & 6 deletions base_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ def on_handshake_challenge(self, data):
def on_chat_received(self, data):
return True

def on_celestial_request(self, data):
return True

def on_universe_time_update(self, data):
return True

Expand Down Expand Up @@ -144,7 +147,7 @@ def on_burn_container(self, data):
def on_clear_container(self, data):
return True

def on_world_update(self, data):
def on_world_client_state_update(self, data):
return True

def on_entity_create(self, data):
Expand All @@ -156,6 +159,9 @@ def on_entity_update(self, data):
def on_entity_destroy(self, data):
return True

def on_hit_request(self, data):
return True

def on_status_effect_request(self, data):
return True

Expand All @@ -177,10 +183,16 @@ def on_damage_notification(self, data):
def on_client_connect(self, data):
return True

def on_client_disconnect(self, player):
def on_client_disconnect_request(self, player):
return True

def on_player_warp(self, data):
return True

def on_fly_ship(self, data):
return True

def on_warp_command(self, data):
def on_central_structure_update(self, data):
return True

def after_protocol_version(self, data):
Expand All @@ -195,6 +207,9 @@ def after_handshake_challenge(self, data):
def after_chat_received(self, data):
return True

def after_celestial_request(self, data):
return True

def after_universe_time_update(self, data):
return True

Expand Down Expand Up @@ -285,7 +300,7 @@ def after_burn_container(self, data):
def after_clear_container(self, data):
return True

def after_world_update(self, data):
def after_world_client_state_update(self, data):
return True

def after_entity_create(self, data):
Expand All @@ -297,6 +312,9 @@ def after_entity_update(self, data):
def after_entity_destroy(self, data):
return True

def after_hit_request(self, data):
return True

def after_status_effect_request(self, data):
return True

Expand All @@ -318,10 +336,16 @@ def after_damage_notification(self, data):
def after_client_connect(self, data):
return True

def after_client_disconnect(self, data):
def after_client_disconnect_request(self, data):
return True

def after_player_warp(self, data):
return True

def after_fly_ship(self, data):
return True

def after_warp_command(self, data):
def after_central_structure_update(self, data):
return True

def __repr__(self):
Expand Down
1 change: 1 addition & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def __init__(self):
def save(self):
try:
with io.open(self.config_path.path, "w", encoding="utf-8") as config:
self.logger.debug("Writing configuration file.")
config.write(json.dumps(self.config, indent=4, separators=(',', ': '), sort_keys=True, ensure_ascii=False))
except Exception as e:
self.logger.critical("Tried to save the configuration file, failed.\n%s", str(e))
Expand Down
84 changes: 40 additions & 44 deletions config/config.json.default
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
},
"command_prefix": "/",
"core_plugin_path": "core_plugins",
"debug_file": "debug.log",
"logging_format_console": "%(asctime)s - %(name)s - %(levelname)s - %(message)s",
"logging_format_debugfile": "%(asctime)s - %(name)s - %(levelname)s - %(message)s",
"logging_format_logfile": "%(asctime)s - %(name)s - %(levelname)s - %(message)s",
"log_level": "DEBUG",
"owner_uuid": "!!--REPLACE THIS--!!",
"passthrough": false,
"player_db": "config/player.db",
Expand All @@ -26,8 +23,8 @@
"auto_activate": true
},
"afk_plugin": {
"afk_msg": "is now AFK",
"afkreturn_msg": "has returned",
"afk_msg": "^gray;is now AFK.",
"afkreturn_msg": "^gray;has returned.",
"auto_activate": true
},
"announcer_plugin": {
Expand All @@ -44,7 +41,8 @@
},
"claims": {
"auto_activate": true,
"max_claims": 5
"max_claims": 5,
"unclaimable_planets": []
},
"colored_names_plugin": {
"auto_activate": true
Expand All @@ -56,12 +54,12 @@
"auto_activate": true
},
"fuelgiver_plugin": {
"auto_activate": true
"auto_activate": false
},
"irc": {
"auto_activate": false,
"bot_nickname": "botname",
"channel": "#channel",
"bot_nickname": "StarryPyBot",
"channel": "##test",
"color": "^#e39313;",
"echo_from_channel": true,
"nickserv_password": "password",
Expand All @@ -71,6 +69,9 @@
"loginwho_plugin": {
"auto_activate": true
},
"mod_chatter": {
"auto_activate": true
},
"motd_plugin": {
"auto_activate": true,
"motd": "Welcome to the server! Play nice."
Expand All @@ -79,40 +80,18 @@
"auto_activate": true
},
"new_player_greeter_plugin": {
"auto_activate": true,
"items": [
],
"message": "Welcome new Starbounder ;)"
},
"starteritems_plugin": {
"auto_activate": true,
"auto_activate": false,
"items": [
[ "bandage", 5 ],
[ "burger", 2 ],
[ "stoneaxe", 1 ],
[ "stonehoe", 1 ],
[ "stonepickaxe", 1 ],
[ "solariumore", 20 ]
[
"coalore",
200
]
],
"message": "You were given a set of starter items ;)"
"message": "Welcome to the server!"
},
"planet_protect": {
"auto_activate": true,
"protect_everything": false,
"bad_packets": [
"CONNECT_WIRE",
"DISCONNECT_ALL_WIRES",
"SWAP_IN_CONTAINER",
"DAMAGE_TILE",
"DAMAGE_TILE_GROUP",
"MODIFY_TILE_LIST"
],
"bad_packets_ship": [
"ENTITY_INTERACT",
"OPEN_CONTAINER",
"CLOSE_CONTAINER"
],
"bad_packets_mild": [
"CONNECT_WIRE",
"DISCONNECT_ALL_WIRES",
"DAMAGE_TILE",
Expand Down Expand Up @@ -194,28 +173,45 @@
"spinningrocket",
"stationaryrocket"
],
"player_planets": {},
"protected_planets": []
"player_planets": {
},
"protect_everything": false,
"protected_planets": [
]
},
"planet_visitor_announcer_plugin": {
"auto_activate": true
},
"player_manager": {
"admin_ss": "tester",
"auto_activate": true,
"name_removal_regexes": [
"\\^#[\\w]+;",
"[^ \\w]+"
]
},
"planet_visitor_announcer_plugin": {
"auto_activate": true
},
"players_plugin": {
"auto_activate": true
},
"plugin_manager": {
"auto_activate": true
},
"poi_plugin": {
"auto_activate": true
},
"starbound_config_manager": {
"auto_activate": true
},
"starteritems_plugin": {
"auto_activate": false,
"message": "Enjoy these gifts from us!",
"items": [
[
"coalore",
200
]
]
},
"uptime_plugin": {
"auto_activate": true
},
Expand All @@ -230,7 +226,7 @@
"cookie_token": "",
"log_path": "webgui.log",
"log_path_access": "webgui_access.log",
"ownerpassword": "!!PUT A PASSWORD HERE",
"ownerpassword": "--ADD PASSWORD--",
"port": 8083,
"remember_cookie_token": true,
"restart_script": ""
Expand Down
1 change: 1 addition & 0 deletions config/pois.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[["-30562840:658406569:-263745435:4:0", "forest"], ["-30562840:658406569:-263745435:3:6", "spawn"]]
7 changes: 6 additions & 1 deletion packet_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,13 @@ def check_packet(self):
z = zlib.decompressobj()
p_parsed.data = z.decompress(p_parsed.data)
except zlib.error:

self.logger.error("Decompression error in check_packet.")
self.logger.debug("Parsed packet:")
self.logger.debug(pprint.pformat(p_parsed))
self.logger.debug("Packet data:")
self.logger.debug(pprint.pformat(p_parsed.original_data.encode("hex")))
self.logger.debug("Following packet data:")
self.logger.debug(pprint.pformat(self._stream.encode("hex")))
raise
packet = Packet(packet_id=p_parsed.id, payload_size=p_parsed.payload_size, data=p_parsed.data,
original_data=p, direction=self.direction)
Expand Down
35 changes: 32 additions & 3 deletions packets/data_types.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
from construct import Construct, Struct, Byte, BFloat64, Flag, \
String, Container
String, Container, Field
from construct.core import _read_stream, _write_stream, Adapter


Expand Down Expand Up @@ -75,10 +75,10 @@ def _encode(self, obj, context):
return obj
def _decode(self, obj, context):
return "".join(obj)

star_string_struct = lambda name="star_string": Struct(name,
VLQ("length"),
String("string", lambda ctx: ctx.length)
)
String("string", lambda ctx: ctx.length))

class VariantVariant(Construct):
def _parse(self, stream, context):
Expand All @@ -95,6 +95,35 @@ def _parse(self, stream, context):
c[key] = value
return c

class WarpVariant(Construct):
# Not all variants have been properly treated!
def _parse(self, stream, context):
x = Byte("").parse_stream(stream)
if x == 0:
return None
elif x == 1:
return star_string().parse_stream(stream)
elif x == 2:
return None
elif x == 3:
flag = Flag("").parse_stream(stream)
return Field("", 16).parse_stream(stream).encode("hex")
elif x == 4:
return star_string().parse_stream(stream)
def _build(self, obj, stream, context):
if len(obj) == 32:
_write_stream(stream, 1, chr(3))
_write_stream(stream, 1, chr(1))
_write_stream(stream, len(obj.decode("hex")), obj.decode("hex"))
return
elif obj is "outpost":
_write_stream(stream, 1, chr(1))
star_string()._build(obj, stream, context)
return
elif obj is None:
_write_stream(stream, 1, chr(4))
_write_stream(stream, 1, chr(0))
return

class Variant(Construct):
def _parse(self, stream, context):
Expand Down
Loading

0 comments on commit f020179

Please sign in to comment.