mirror of
https://github.com/barronwaffles/dwc_network_server_emulator.git
synced 2026-04-24 07:16:57 -05:00
Fix some indentation errors
- Fixed some errors made last night while formatting the code using PyCharm. - Added more documentation for the \bm\ command on the GameSpy server. - Added some documentation for the opcodes used on the master server.
This commit is contained in:
parent
eae79e9def
commit
63a173cf1f
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -219,4 +219,6 @@ pip-log.txt
|
|||
.idea/nintendo_dwc_emulator.iml
|
||||
.idea/scopes/scope_settings.xml
|
||||
.idea/vcs.xml
|
||||
.idea/workspace.xml
|
||||
.idea/workspace.xml
|
||||
gpcm.db
|
||||
.idea/dictionaries/Nagato.xml
|
||||
|
|
@ -92,7 +92,9 @@ class GamespyDatabase(object):
|
|||
if self.check_user_exists(userid) == 0:
|
||||
profileid = self.get_next_free_profileid()
|
||||
|
||||
pid = "11" # Always 11??? Is this important? Not to be confused with dwc_pid. The three games I found it in (Tetris DS, Advance Wars - Days of Ruin, and Animal Crossing: Wild World) all use \pid\11.
|
||||
pid = "11" # Always 11??? Is this important? Not to be confused with dwc_pid.
|
||||
# The three games I found it in (Tetris DS, Advance Wars - Days of Ruin, and
|
||||
# Animal Crossing: Wild World) all use \pid\11.
|
||||
lon = "0.000000" # Always 0.000000?
|
||||
lat = "0.000000" # Always 0.000000?
|
||||
loc = "" # Always blank?
|
||||
|
|
@ -166,50 +168,46 @@ class GamespyDatabase(object):
|
|||
c.close()
|
||||
return profile
|
||||
|
||||
|
||||
def generate_session_key(self, min_size):
|
||||
session_key = utils.generate_random_number_str(min_size)
|
||||
|
||||
c = self.conn.cursor()
|
||||
for r in c.execute("SELECT session FROM sessions WHERE session = ?", [session_key]):
|
||||
def generate_session_key(self, min_size):
|
||||
session_key = utils.generate_random_number_str(min_size)
|
||||
|
||||
return session_key
|
||||
c = self.conn.cursor()
|
||||
for r in c.execute("SELECT session FROM sessions WHERE session = ?", [session_key]):
|
||||
session_key = utils.generate_random_number_str(min_size)
|
||||
|
||||
return session_key
|
||||
|
||||
def create_session(self, profileid):
|
||||
if profileid != None and self.check_profile_exists(profileid) == False:
|
||||
return None
|
||||
def delete_session(self, profileid):
|
||||
c = self.conn.cursor()
|
||||
c.execute("DELETE FROM sessions WHERE profileid = ?", [profileid])
|
||||
self.conn.commit()
|
||||
|
||||
# Remove any old sessions associated with this user id
|
||||
self.delete_session(profileid)
|
||||
def create_session(self, profileid):
|
||||
if profileid != None and self.check_profile_exists(profileid) == False:
|
||||
return None
|
||||
|
||||
# Create new session
|
||||
session_key = self.generate_session_key(9)
|
||||
# Remove any old sessions associated with this user id
|
||||
self.delete_session(profileid)
|
||||
|
||||
c = self.conn.cursor()
|
||||
c.execute("INSERT INTO sessions VALUES (?, ?)", [session_key, profileid])
|
||||
self.conn.commit()
|
||||
# Create new session
|
||||
session_key = self.generate_session_key(9)
|
||||
|
||||
return session_key
|
||||
c = self.conn.cursor()
|
||||
c.execute("INSERT INTO sessions VALUES (?, ?)", [session_key, profileid])
|
||||
self.conn.commit()
|
||||
|
||||
return session_key
|
||||
|
||||
def delete_session(self, profileid):
|
||||
c = self.conn.cursor()
|
||||
c.execute("DELETE FROM sessions WHERE profileid = ?", [profileid])
|
||||
self.conn.commit()
|
||||
def get_session_list(self, profileid=None):
|
||||
c = self.conn.cursor()
|
||||
|
||||
sessions = []
|
||||
if profileid != None:
|
||||
r = c.execute("SELECT * FROM sessions WHERE profileid = ?", [profileid])
|
||||
else:
|
||||
r = c.execute("SELECT * FROM sessions")
|
||||
|
||||
def get_session_list(self, profileid=None):
|
||||
c = self.conn.cursor()
|
||||
for row in r:
|
||||
sessions.append(self.get_dict(row))
|
||||
|
||||
sessions = []
|
||||
if profileid != None:
|
||||
r = c.execute("SELECT * FROM sessions WHERE profileid = ?", [profileid])
|
||||
else:
|
||||
r = c.execute("SELECT * FROM sessions")
|
||||
|
||||
for row in r:
|
||||
sessions.append(self.get_dict(row))
|
||||
|
||||
return sessions
|
||||
return sessions
|
||||
|
|
|
|||
|
|
@ -119,6 +119,40 @@ while 1:
|
|||
# Handle status update
|
||||
msg = ""
|
||||
|
||||
elif data_parsed['__cmd__'] == "ka":
|
||||
# Unknown
|
||||
|
||||
msg = ""
|
||||
|
||||
elif data_parsed['__cmd__'] == "bm":
|
||||
# Friends list-related
|
||||
#
|
||||
# Example of friend logging in:
|
||||
# \bm\100\f\217936895\msg\|s|1|ss||ls||ip|-1405615422|p|0|qm|0\final\
|
||||
# \bm\100\f\217936895\msg\|s|1|ss||ls|97YBAAAAAAAAAAAA-wA*|ip|-1405615422|p|0|qm|0\final\
|
||||
#
|
||||
# Example of friend hosting game:
|
||||
# \bm\100\f\217936895\msg\|s|1|ss||ls|97YBAAAAAAAAAAAAAAA*|ip|-1405615422|p|0|qm|0\final\
|
||||
# \bm\100\f\217936895\msg\|s|6|ss|/SCM/2/SCN/1/VER/3|ls|97YBAAAAAAAAAAAAAAA*|ip|-1405615422|p|0|qm|0\final\
|
||||
#
|
||||
# Example of friend closing game:
|
||||
# \bm\100\f\217936895\msg\|s|1|ss||ls|97YBAAAAAAAAAAAAAAA*|ip|-1405615422|p|0|qm|0\final\
|
||||
# \bm\100\f\217936895\msg\|s|1|ss||ls|97YBAAAAAAAAAAAA-wA*|ip|-1405615422|p|0|qm|0\final\
|
||||
#
|
||||
# Example of friend hosting game again:
|
||||
# \bm\100\f\217936895\msg\|s|1|ss||ls|97YBAAAAAAAAAAAAAAA*|ip|-1405615422|p|0|qm|0\final\
|
||||
# \bm\100\f\217936895\msg\|s|6|ss|/SCM/2/SCN/1/VER/3|ls|97YBAAAAAAAAAAAAAAA*|ip|-1405615422|p|0|qm|0\final\
|
||||
#
|
||||
# Join game with friend:
|
||||
# (CLIENT) \status\5\sesskey\233209064\statstring\\locstring\JZoAAAAAAAAAAAAA-wA*\final\
|
||||
# (CLIENT) \bm\1\sesskey\233209064\t\217936895\msg\GPCM3vMAT.3/2371876423/58891\final\
|
||||
# (SERVER) \bm\1\f\217936895\msg\GPCM3vMAT.0/3254925484/27496\final\
|
||||
# (SERVER) \bm\100\f\217936895\msg\|s|6|ss|/SCM/2/SCN/2/VER/3|ls|97YBAAAAAAAAAAAAAAA*|ip|-1405615422|p|0|qm|0\final\
|
||||
# (CLIENT) \status\2\sesskey\233209064\statstring\\locstring\JZoAAAAAAAAAAAAA-wA*\final\
|
||||
# (SERVER) \bm\100\f\217936895\msg\|s|6|ss|/SCM/2/SCN/2/VER/3|ls|97YBAAAAAAAAAAAA-wA*|ip|-1405615422|p|0|qm|0\final\
|
||||
# (SERVER) \bm\100\f\217936895\msg\|s|6|ss|/SCM/2/SCN/1/VER/3|ls|97YBAAAAAAAAAAAA-wA*|ip|-1405615422|p|0|qm|0\final\
|
||||
msg = ""
|
||||
|
||||
elif data_parsed['__cmd__'] == "logout":
|
||||
print "Session %s has logged off" % (data_parsed['sesskey'])
|
||||
db.delete_session(data_parsed['sesskey'])
|
||||
|
|
|
|||
|
|
@ -23,10 +23,11 @@ while 1:
|
|||
# - All server messages seem to always start with \xfe\xfe.
|
||||
# - The first byte from the client (or third byte from the server) is a command.
|
||||
# - Bytes 2 - 5 from the client is some kind of ID. This will have to be inspected later. I believe it's a
|
||||
# session-like ID because the number changes between connections.
|
||||
# session-like ID because the number changes between connections. Copying the client's ID might be enough.
|
||||
#
|
||||
# - Commands
|
||||
# CLIENT:
|
||||
# 0x01 - Unknown
|
||||
# 0x03 - Send client state?
|
||||
# 0x07 - Unknown, related to server's 0x06 (returns value sent from server)
|
||||
# 0x08 - Keep alive?
|
||||
|
|
@ -35,7 +36,9 @@ while 1:
|
|||
# 0x01 - Unknown
|
||||
# 0x06 - Unknown
|
||||
# 0x0a - Unknown
|
||||
|
||||
#
|
||||
# - \xfd\xfc commands get passed directly between the other player(s)?
|
||||
|
||||
if [ord(x) for x in recv_data[0:5]] == [0x09, 0x00, 0x00, 0x00, 0x00]:
|
||||
utils.print_log("Received request for '%s' from %s:%s... %s" % (
|
||||
get_game_id(recv_data), addr[0], addr[1], [elem.encode("hex") for elem in recv_data]))
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user