World Objects, Game Message 888, Temporary Bin

Implemented storing World Objects in the sql database as well as updating them, Started working towards implementing game message 888, current sending a construction from the a bin found in GruntMonkey's packet capture, probably gonna keep it this way until I figure out the problem :/
This commit is contained in:
wesleyd1124
2018-04-19 17:08:33 -04:00
committed by GitHub
parent 5b023a4dfc
commit 54bdeea09c
4 changed files with 82 additions and 33 deletions
+17 -1
View File
@@ -51,6 +51,7 @@ def DBServerStarup():
conn = sqlite3.connect("server.sqlite")
c = conn.cursor()
c.execute("DELETE FROM CurrentSessions")
c.execute("DELETE FROM World_Objects WHERE LOT = 1")
c.execute("DELETE FROM Worlds")
conn.commit()
conn.close()
@@ -309,6 +310,21 @@ def updateSessionByUserKey(userkey, state, zoneID, charID):
def updateSessionByAccountID(accountID, state, zoneID, charID):
conn = sqlite3.connect("server.sqlite")
c = conn.cursor()
c.execute("UPDATE CurrentSessions SET charID = "+charID+", zoneID = "+zoneID+", State = "+state+" WHERE AccountID = "+accountID)
c.execute("UPDATE CurrentSessions SET charID = "+str(charID)+", zoneID = "+str(zoneID)+", State = "+str(state)+" WHERE AccountID = "+str(accountID))
conn.commit()
conn.close()
def registerWorldObject(Name, LOT, ObjectID, Zone, posX, posY, posZ, rotX, rotY, rotZ, rotW):
conn = sqlite3.connect("server.sqlite")
c = conn.cursor()
c.execute(
"INSERT INTO World_Objects (Name, LOT, ObjectID, Zone, posX, posY, posZ, rotX, rotY, rotZ, rotw) VALUES ('"+str(Name)+"', "+str(LOT)+", "+str(ObjectID)+", "+str(Zone)+", "+str(posX)+", "+str(posY)+", "+str(posZ)+", "+str(rotX)+", "+str(rotY)+", "+str(rotZ)+", "+str(rotW)+")")
conn.commit()
conn.close()
def updateWorldObject(ObjectID, posX, posY, posZ, rotX, rotY, rotZ, rotW):
conn = sqlite3.connect("server.sqlite")
c = conn.cursor()
c.execute("UPDATE World_Objects SET posX = " + str(posX) + ", posY = " + str(posY) + ", posZ = " + str(posZ) + ", rotX = " + str(rotX) + ", rotY = " + str(rotY) + ", rotZ = " + str(rotZ) + ", rotW = " + str(rotW) + " WHERE ObjectID = " + str(ObjectID))
conn.commit()
conn.close()
+3 -6
View File
@@ -439,11 +439,8 @@ class StatsIndex():
self.flag2 = False
self.currentHealth = c_ulong(20)#Ulong
self.weirdFloat1 = c_float(1)
self.currentArmor = c_ulong(20)#Ulong
self.weirdFloat2 = c_float(1)
self.currentImagination = c_ulong(20)#Ulong
self.weirdFloat3 = c_float(1)
self.data2_1 = c_ulong(0)
self.data2_2 = c_bit(False)
self.data2_3 = c_bit(False)
@@ -480,11 +477,11 @@ class StatsIndex():
packet.write(c_bit(self.flag2))
if(self.flag2 == True):
packet.write(self.currentHealth)
packet.write(self.weirdFloat1)
packet.write(self.maxHealth)
packet.write(self.currentArmor)
packet.write(self.weirdFloat2)
packet.write(self.maxArmor)
packet.write(self.currentImagination)
packet.write(self.weirdFloat3)
packet.write(self.maxImagination)
packet.write(self.data2_1)
packet.write(self.data2_2)
packet.write(self.data2_3)
+62 -26
View File
@@ -317,7 +317,8 @@ class WorldServer(server.Server):
objidKeyAdj.write("objid", allocated_length=(b"objid".__len__()*2)+2) # Write encoded key as bits
LDF.write(objidKeyAdj[:-2])#Remove 2 unnecessary bits
LDF.write(c_ubyte(9)) # Write data format 9
LDF.write(c_int64(int(characterData[3])))#Write int(characterData[3])
LDF.write(c_int64(1152921510436607007))
#LDF.write(c_int64(int(characterData[3])))#Write int(characterData[3])
keyNumber = keyNumber + 1
reputationKeyAdj = BitStream()
@@ -370,23 +371,25 @@ class WorldServer(server.Server):
xml = xml + '</mis>'#If there are no missions write nothing
xml = xml + "<mnt/><dest/></obj>"#Idk what these three are. Should probably find that out
xmlKeyAdj = BitStream()
LDF.write(c_ubyte((b"xml".__len__() * 2)))
xmlKeyAdj.write("xml", allocated_length=(b"xml".__len__()*2)+2) # Write encoded key as bits
LDF.write(xmlKeyAdj[:-2])
LDF.write(c_ubyte(13)) # Write data format
xmlData = xml.encode("utf-16-le")#XML has format 13
LDF.write(c_ulong(len(xmlData))) # xml length
LDF.write_bits(xmlData) # xml data
keyNumber = keyNumber + 1
# xmlKeyAdj = BitStream()
# LDF.write(c_ubyte((b"xml".__len__() * 2)))
# xmlKeyAdj.write("xml", allocated_length=(b"xml".__len__()*2)+2) # Write encoded key as bits
# LDF.write(xmlKeyAdj[:-2])
# LDF.write(c_ubyte(13)) # Write data format
# xmlData = xml.encode("utf-16-le")#XML has format 13
# LDF.write(c_ulong(len(xmlData))) # xml length
# LDF.write_bits(xmlData) # xml data
# keyNumber = keyNumber + 1
nameKeyAdj = BitStream()
LDF.write(c_ubyte((b"name".__len__() * 2)))
nameKeyAdj.write("name", allocated_length=(b"name".__len__()*2)+2) # Write encoded key as bits
LDF.write(nameKeyAdj[:-2])
LDF.write(c_ubyte(0)) # Write data format 0
LDF.write(c_uint((str(characterData[2]).__len__()*2)+2))#Write String Length
LDF.write(str(characterData[2]), allocated_length=(str(characterData[2]).__len__()*2)+2) # String
# LDF.write(c_uint((str(characterData[2]).__len__()*2)+2))#Write String Length
# LDF.write(str(characterData[2]), allocated_length=(str(characterData[2]).__len__()*2)+2) # String
LDF.write(c_uint((str("GruntMonkey").__len__()*2)+2))#Write String Length
LDF.write(str("GruntMonkey"), allocated_length=(str("GruntMonkey").__len__()*2)+2) # String
keyNumber = keyNumber + 1
adjLDF = BitStream()#Create Final LDF Stream
@@ -401,6 +404,10 @@ class WorldServer(server.Server):
finalPacket.write(adjLDF) # Writes all the LDF data
registerWorldObject("GruntMonkey", 1, 1152921510436607007, zoneID, -627.1862182617188,
613.3262329101562, -17.223167419433594, 0, 0.7334349751472473, 0, 0.6797596216201782)
#registerWorldObject(str(characterData[2]), 1, str(characterData[3]), zoneID, int(characterData[17]),int(characterData[18]),int(characterData[19]),0,0,0,0)
self.send(finalPacket, address, reliability=PacketReliability.ReliableOrdered)
# InfoFile = open(os.getcwd()+"\\TestPackets\\DetailedUserInfo.bin", "rb")
@@ -412,20 +419,30 @@ class WorldServer(server.Server):
#Add Base Data
Player = BaseData()
Player.objectID = c_int64(int(characterData[3]))
Player.objectID = c_int64(1152921510436607007)
#Player.objectID = c_int64(int(characterData[3]))
Player.LOT = c_long(1)
Player.flag6 = True
Player.NameLength = (str(characterData[2]).__len__())
Player.Name = str(characterData[2])
Player.NameLength = (str("GruntMonkey").__len__())
Player.Name = "GruntMonkey"
#Player.NameLength = (str(characterData[2]).__len__())
#Player.Name = str(characterData[2])
#Add Controllable Physics
ControllablePhysics = ControllablePhysicsComponent()
ControllablePhysics.flag2 = True
ControllablePhysics.flag4 = True
ControllablePhysics.vectorFlag = True
ControllablePhysics.xPos = c_float(int(characterData[17]))
ControllablePhysics.yPos = c_float(int(characterData[18]))
ControllablePhysics.zPos = c_float(int(characterData[19]))
ControllablePhysics.xPos = c_float(-627.1862182617188)
ControllablePhysics.yPos = c_float(613.3262329101562)
ControllablePhysics.zPos = c_float(-17.223167419433594)
ControllablePhysics.xRot = c_float(0.0)
ControllablePhysics.yRot = c_float(0.7334349751472473)
ControllablePhysics.zRot = c_float(0.0)
ControllablePhysics.wRot = c_float(0.6797596216201782)
#ControllablePhysics.xPos = c_float(int(characterData[17]))
#ControllablePhysics.yPos = c_float(int(characterData[18]))
#ControllablePhysics.zPos = c_float(int(characterData[19]))
ControllablePhysics.onGround=True
@@ -436,12 +453,19 @@ class WorldServer(server.Server):
#Add Stats
Stats = StatsIndex()
Stats.flag1 = True
Stats.currentHealth = c_ulong(4)
Stats.maxHealth = c_float(4)
Stats.currentArmor = c_ulong(0)
Stats.maxArmor = c_float(0)
Stats.currentImagination = c_ulong(0)
Stats.maxImagination = c_float(0)
Stats.flag2 = True
#Add Character Component
Character = CharacterComponent()
Character.hasLevel = True
Character.level = c_ulong(characterData[20])
Character.level = c_ulong(1)
#Character.level = c_ulong(characterData[20])
info = PlayerInfo()
info.setInfo(characterData[3])
Character.info = info
@@ -474,12 +498,12 @@ class WorldServer(server.Server):
PlayerComponents = [Player, ControllablePhysics, Destructible, Stats, Character, Inventory, Script, Skill, Render, Comp107]
PlayerObject = ReplicaObject(PlayerComponents)
PlayerObject._serialize = True
self.RM.construct(PlayerObject, constructMsg="Sent Player", logFile="1_2002-51995_2_[24].bin")
#self.RM.construct(PlayerObject, constructMsg="Sent Player", logFile="1_2002-51995_2_[24].bin")
# ConstructionFile = open(os.getcwd()+"\\TestPackets\\CharacterConstruction.bin", "rb")
# constructionPacket = BitStream()
# constructionPacket.write(ConstructionFile.read())
# self.send(constructionPacket, address)
ConstructionFile = open(os.getcwd()+"\\TestPackets\\CharacterConstruction.bin", "rb")
constructionPacket = BitStream()
constructionPacket.write(ConstructionFile.read())
self.send(constructionPacket, address)
self.GM.SendGameMessage(1642, int(characterData[3]), address)#Server done loading all objects
elif(data[0:3] == b"\x04\x00\x05"):
@@ -497,7 +521,10 @@ class WorldServer(server.Server):
print("[" + self.role + "]" + "Emote ID:" + str(emoteID) + ", Target ID: " + str(targetID))
elif(str(msgID) == "505"):
playerID = GM.read(c_longlong)
print("[" + self.role + "]" + "Player with ID: " + str(playerID) + " has loaded!")
print("[" + self.role + "]" + "Player with ID: " + str(playerID) + " has loaded")
elif(str(msgID) == "888"):
objectID = GM.read(c_longlong)
print("[" + self.role + "]" + "Object " + str(objectID) + " needs an update")
else:
print("[" + self.role + "]" + "Message currently has no handler and is not defined!")
elif(data[0:3] == b"\x04\x00\x15"):
@@ -506,7 +533,16 @@ class WorldServer(server.Server):
#print(data[11:])
elif(data[0:3] == b"\x04\x00\x16"):
#print("[" + self.role + "]" + "Lego Packet was Position/Rotation Update")
PlaceHolder = None
session = getSessionByAddress(address)
info = BitStream(data[7:])
posX = info.read(c_float)
posY = info.read(c_float)
posZ = info.read(c_float)
rotX = info.read(c_float)
rotY = info.read(c_float)
rotZ = info.read(c_float)
rotW = info.read(c_float)
updateWorldObject(session[0][4], posX, posY, posZ, rotX, rotY, rotZ, rotW)
#Not going to even print this to console because it updates so much
else:
print("[" + self.role + "]" + "Received Unknown Packet:")
BIN
View File
Binary file not shown.