mirror of
https://github.com/lcdr/luserver.git
synced 2026-05-12 23:08:20 -05:00
v2017.06.23
- fixed relative paths - fixed instance spawning
This commit is contained in:
@@ -274,7 +274,7 @@ class SendCommand(ChatCommand):
|
||||
if not args.broadcast and args.address is None:
|
||||
args.address = sender.char.address
|
||||
|
||||
path = os.path.join(__file__, "..", "..", "..", "runtime", "packets", args.directory)
|
||||
path = os.path.normpath(os.path.join(__file__, "..", "..", "..", "runtime", "packets", args.directory))
|
||||
files = os.listdir(path)
|
||||
files.sort(key=lambda text: [int(text) if text.isdigit() else text for c in re.split(r"(\d+)", text)]) # sort using numerical values
|
||||
for file in files:
|
||||
|
||||
@@ -163,14 +163,17 @@ class CharacterComponent(Component, CharMission, CharTrade):
|
||||
|
||||
def serialize(self, out, is_creation):
|
||||
# First index
|
||||
out.write(c_bit(self.vehicle_flag))
|
||||
if self.vehicle_flag:
|
||||
out.write(c_bit(self.vehicle_id_flag))
|
||||
if self.vehicle_id_flag:
|
||||
creation = is_creation and self.vehicle_id != 0
|
||||
out.write(c_bit(creation or self.vehicle_flag))
|
||||
if creation or self.vehicle_flag:
|
||||
out.write(c_bit(creation or self.vehicle_id_flag))
|
||||
if creation or self.vehicle_id_flag:
|
||||
out.write(c_int64(self.vehicle_id))
|
||||
self.vehicle_id_flag = False
|
||||
if not creation:
|
||||
self.vehicle_id_flag = False
|
||||
out.write(c_ubyte(1)) # unknown
|
||||
self.vehicle_flag = False
|
||||
if not creation:
|
||||
self.vehicle_flag = False
|
||||
|
||||
# Second index
|
||||
out.write(c_bit(self.level_flag or is_creation))
|
||||
|
||||
@@ -118,9 +118,10 @@ class InventoryComponent(Component):
|
||||
def __init__(self, obj, set_vars, comp_id):
|
||||
super().__init__(obj, set_vars, comp_id)
|
||||
self.object.inventory = self
|
||||
self.equipped_items_flag = False
|
||||
self._flags["equipped"] = "equipped_items_flag"
|
||||
self.equipped = PersistentList()
|
||||
self.equipped.append(PersistentList()) # current equip state
|
||||
self.attr_changed("equipped")
|
||||
self.items = PersistentList([None]*20)
|
||||
self.bricks = PersistentList()
|
||||
self.temp_items = PersistentList()
|
||||
@@ -136,12 +137,13 @@ class InventoryComponent(Component):
|
||||
self.equip_inventory(item_to_equip=item.object_id)
|
||||
|
||||
def serialize(self, out, is_creation):
|
||||
out.write(c_bit(self.equipped_items_flag or is_creation))
|
||||
if self.equipped_items_flag or is_creation:
|
||||
out.write(c_bit(is_creation or self.equipped_items_flag))
|
||||
if is_creation or self.equipped_items_flag:
|
||||
out.write(c_uint(len(self.equipped[-1])))
|
||||
for item in self.equipped[-1]:
|
||||
item.serialize(out)
|
||||
self.equipped_items_flag = False
|
||||
if not is_creation:
|
||||
self.equipped_items_flag = False
|
||||
out.write(c_bit(False))
|
||||
|
||||
def inventory_type_to_inventory(self, inventory_type):
|
||||
@@ -163,7 +165,7 @@ class InventoryComponent(Component):
|
||||
|
||||
def push_equipped_items_state(self):
|
||||
self.equipped.append(self.equipped[-1].copy())
|
||||
self.equipped_items_flag = True
|
||||
self.attr_changed("equipped")
|
||||
|
||||
def pop_equipped_items_state(self):
|
||||
if len(self.equipped) == 1:
|
||||
@@ -197,7 +199,7 @@ class InventoryComponent(Component):
|
||||
self.un_equip_inventory(item_to_unequip=equipped_item.object_id)
|
||||
|
||||
del self.equipped[-2]
|
||||
self.equipped_items_flag = True
|
||||
self.attr_changed("equipped")
|
||||
|
||||
def move_item_in_inventory(self, dest_inventory_type:c_int=0, object_id:c_int64=None, inventory_type:c_int=None, response_code:c_int=None, slot:c_int=None):
|
||||
assert dest_inventory_type == 0
|
||||
@@ -366,8 +368,7 @@ class InventoryComponent(Component):
|
||||
break
|
||||
|
||||
self.equipped[-1].append(item)
|
||||
self.equipped_items_flag = True
|
||||
self.object.signal_serialize()
|
||||
self.attr_changed("equipped")
|
||||
|
||||
if hasattr(self.object, "char"):
|
||||
self.object.skill.add_skill_for_item(item)
|
||||
@@ -404,8 +405,7 @@ class InventoryComponent(Component):
|
||||
for item in self.equipped[-1]:
|
||||
if item.object_id == item_to_unequip:
|
||||
self.equipped[-1].remove(item)
|
||||
self.equipped_items_flag = True
|
||||
self.object.signal_serialize()
|
||||
self.attr_changed("equipped")
|
||||
|
||||
if hasattr(self.object, "char"):
|
||||
self.object.skill.remove_skill_for_item(item)
|
||||
|
||||
@@ -76,7 +76,7 @@ class ChatHandling(ServerModule):
|
||||
self.commands = self.chat_parser.add_subparsers(title="Available commands", parser_class=lambda *args, **kwargs: CustomArgumentParser(*args, chat=self, **kwargs))
|
||||
|
||||
cmds = []
|
||||
cmd_dir = os.path.abspath(os.path.join(__file__, "..", "..", "commands"))
|
||||
cmd_dir = os.path.normpath(os.path.join(__file__, "..", "..", "commands"))
|
||||
|
||||
for filename in os.listdir(cmd_dir):
|
||||
name, ext = os.path.splitext(filename)
|
||||
|
||||
+2
-2
@@ -108,11 +108,11 @@ class Server(pyraknet.server.Server):
|
||||
continue
|
||||
return server_address
|
||||
# no server found, spawn a new one
|
||||
command = os.path.join(__file__, "..", "..", "runtime", "__main__.py")+" %i %i" % (world_id[0], world_id[2])
|
||||
command = os.path.normpath(os.path.join(__file__, "..", "..", "runtime", "__main__.py"))+" %i %i" % (world_id[0], world_id[2])
|
||||
if os.name == "nt":
|
||||
subprocess.Popen("cmd /K \"python "+command+" && exit || pause && exit\"", creationflags=subprocess.CREATE_NEW_CONSOLE)
|
||||
else:
|
||||
subprocess.Popen("python3 "+command)
|
||||
subprocess.Popen("python3 "+command, shell=True)
|
||||
if first:
|
||||
await asyncio.sleep(8)
|
||||
first = False
|
||||
|
||||
+1
-2
@@ -106,7 +106,6 @@ class WorldServer(server.Server, pyraknet.replicamanager.ReplicaManager):
|
||||
self.commit()
|
||||
|
||||
def shutdown(self):
|
||||
self.conn_sync()
|
||||
for address in self.accounts.copy():
|
||||
self.close_connection(address, server.DisconnectReason.ServerShutdown)
|
||||
del self.db.servers[self.external_address]
|
||||
@@ -122,7 +121,7 @@ class WorldServer(server.Server, pyraknet.replicamanager.ReplicaManager):
|
||||
console_log = True
|
||||
|
||||
if packetname in self.file_logged_packets:
|
||||
with open(os.path.join(__file__, "..", "..", "runtime", "logs", packetname+str(time.time())+".bin"), "wb") as file:
|
||||
with open(os.path.normpath(os.path.join(__file__, "..", "..", "runtime", "logs", packetname+str(time.time())+".bin")), "wb") as file:
|
||||
file.write(data)
|
||||
|
||||
if console_log:
|
||||
|
||||
+2
-2
@@ -12,7 +12,7 @@ from luserver.auth import AuthServer
|
||||
from luserver.world import WorldServer
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
config.read(os.path.join(__file__, "..", "luserver.ini"))
|
||||
config.read(os.path.normpath(os.path.join(__file__, "..", "luserver.ini")))
|
||||
|
||||
logging.basicConfig(format="%(levelname).1s:%(message)s", level=logging.DEBUG)
|
||||
|
||||
@@ -43,7 +43,7 @@ while True:
|
||||
flags = subprocess.CREATE_NEW_CONSOLE
|
||||
else:
|
||||
flags = 0
|
||||
subprocess.Popen("runzeo -a 12345 -f "+os.path.join(__file__, "..", "db", "server_db.db"), creationflags=flags)
|
||||
subprocess.Popen("runzeo -a 12345 -f "+os.path.normpath(os.path.join(__file__, "..", "db", "server_db.db")), shell=True, creationflags=flags)
|
||||
time.sleep(3)
|
||||
|
||||
if len(sys.argv) == 1:
|
||||
|
||||
+6
-3
@@ -19,7 +19,10 @@ import scripts
|
||||
class Init:
|
||||
def __init__(self, gen_accounts, gen_skills, gen_missions, gen_comps, gen_world):
|
||||
self.config = configparser.ConfigParser()
|
||||
self.config.read(os.path.join(__file__, "..", "..", "luserver.ini")
|
||||
config_dir = os.path.normpath(os.path.join(__file__, "..", ".."))
|
||||
self.config.read(os.path.join(config_dir, "luserver.ini"))
|
||||
self.config["paths"]["cdclient_path"] = os.path.normpath(os.path.join(config_dir, self.config["paths"]["cdclient_path"]))
|
||||
self.config["paths"]["client_path"] = os.path.normpath(os.path.join(config_dir, self.config["paths"]["client_path"]))
|
||||
|
||||
while True:
|
||||
try:
|
||||
@@ -30,7 +33,7 @@ class Init:
|
||||
flags = subprocess.CREATE_NEW_CONSOLE
|
||||
else:
|
||||
flags = 0
|
||||
subprocess.Popen("runzeo -a 12345 -f "+ os.path.join(__file__, "..", "server_db.db"), creationflags=flags)
|
||||
subprocess.Popen("runzeo -a 12345 -f "+ os.path.normpath(os.path.join(__file__, "..", "server_db.db")), shell=True, creationflags=flags)
|
||||
time.sleep(3)
|
||||
|
||||
self.root = conn.root
|
||||
@@ -45,7 +48,7 @@ class Init:
|
||||
if gen_comps:
|
||||
self.gen_comps()
|
||||
if gen_world:
|
||||
luz_importer.import_data(self.root, self.config["paths"]["client_path"] + "/res/maps")
|
||||
luz_importer.import_data(self.root, os.path.join(self.config["paths"]["client_path"], "res", "maps"))
|
||||
|
||||
transaction.commit()
|
||||
print("Done initializing database!")
|
||||
|
||||
@@ -21,7 +21,7 @@ def import_data(root, maps_path):
|
||||
World.SpiderQueenBattle: "01_live_maps/avant_gardens/property/small/nd_ag_property_small.luz",
|
||||
World.BlockYard: "01_live_maps/avant_gardens/property/small/nd_ag_property_small.luz",
|
||||
World.AvantGrove: "01_live_maps/avant_gardens/property/medium/nd_ag_property_medium.luz",
|
||||
World.AGPropLarge: "2011_Live_Maps/PP_AG_Large/nd_ag_property_large.luz",
|
||||
World.AGPropLarge: "2011_live_maps/pp_ag_large/nd_ag_property_large.luz",
|
||||
World.NimbusStation: "01_live_maps/nimbus_station/nd_nimbus_station.luz",
|
||||
World.PetCove: "01_live_maps/nimbus_station/pet_ranch/nd_ns_pet_ranch.luz",
|
||||
World.VertigoLoop: "01_live_maps/nimbus_station/racetrack/nd_nimbus_station_racetrack.luz",
|
||||
|
||||
@@ -46,7 +46,7 @@ class Server(pyraknet.server.Server):
|
||||
def input_loop(self):
|
||||
while True:
|
||||
try:
|
||||
path = os.path.join(__file__, "..", "packets", input())
|
||||
path = os.path.normpath(os.path.join(__file__, "..", "packets", input()))
|
||||
files = os.listdir(path)
|
||||
files.sort(key=natural_keys)
|
||||
for file in files:
|
||||
|
||||
Reference in New Issue
Block a user