Skip to content

Commit 12930d4

Browse files
authored
Room instances (#363)
# Description The goal of this PR is to split Room data files into two save forms: 1. The "Template", saved in `_datafiles/world/{worldname}/rooms/` which is just the normal, empty state room definition. This is how the room should be loaded into the memory the first time it is ever encountered. Items shouldn't be on the floor (unless it is desired to start with an item on the floor), gold, containers, etc. are all in their initial state. 2. The "Instance", saved in `_datafiles/world/{worldname}/rooms.instances/` which is everything (or most things) that have changed about the room and are worth saving in case the room gets unloaded from memory. ## Changes - Updated room "Template" data files to remove random objects that were saved and committed into rooms in the past. - Instance loading/saving and Template loading/saving are distinct operations with different purposes, and code functions etc. have been created to handle them. - Developers should generally not have to interface with these, they are for precise modification to specific data when needed, such as in admin commands. The `rooms.LoadRoom()` function remains the primary way to load room data. - Fixed some inefficiencies with room filenames, should have been caching but wasn't. - Added a makefile target to delete all instance data for purposes of testing. - Added an event and handler to rebuild mapper data. - Fixed a lot of messy/poorly named functions and variables to try and make clearer - Added lots of code comments for whatever poor soul must revisit this process. - Moved room save/load functions to own file in package folder. - Updated admin `build` command to modify template data. - Updated admin `room` command to modify template data.
1 parent 539d2e6 commit 12930d4

File tree

27 files changed

+782
-394
lines changed

27 files changed

+782
-394
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ _datafiles/**/users/*
44
_datafiles/**/plugin-data/*
55
**/config-overrides.yaml
66
**/.roundcount
7+
**/rooms.instances
78
vendor/
89
server.crt
910
server.key

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ clean:
6363
$(DOCKER_COMPOSE) down --volumes --remove-orphans
6464
docker system prune -a
6565

66+
.PHONY: clean-instances
67+
clean-instances: ### Deletes all room instance data. Starts the world fresh.
68+
rm -Rf _datafiles/world/default/rooms.instances
69+
rm -Rf _datafiles/world/empty/rooms.instances
70+
6671
## Run Targets
6772

6873
.PHONY: run

_datafiles/world/default/rooms/catacombs/89.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ exits:
1414
roomid: 81
1515
north:
1616
roomid: 88
17-
items:
18-
- itemid: 10002
19-
gold: 6
2017
spawninfo:
2118
- mobid: 15
2219
message: The bones in the room stir, and a skeleton rises from the dirt.

_datafiles/world/default/rooms/dark_forest/878.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ containers:
1818
ornate chest:
1919
lock:
2020
difficulty: 8
21-
items:
22-
- itemid: 25
23-
gold: 1
2421
exits:
2522
out:
2623
roomid: 877

_datafiles/world/default/rooms/endless_trashheap/142.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@ exits:
1616
roomid: 143
1717
west:
1818
roomid: 141
19-
items:
20-
- itemid: 20001
21-
- itemid: 20001
22-
- itemid: 20001
23-
- itemid: 20011
24-
- itemid: 20011
25-
- itemid: 20011
2619
idlemessages:
2720
- the mountain of trash shifts slightly.
2821
- the trash heal trembles, threatening to collapse at any moment.

_datafiles/world/default/rooms/endless_trashheap/152.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ exits:
1616
roomid: 153
1717
south:
1818
roomid: 151
19-
items:
20-
- itemid: 5
2119
idlemessages:
2220
- the mountain of trash shifts slightly.
2321
- the trash heal trembles, threatening to collapse at any moment.

_datafiles/world/default/rooms/frost_lake/828.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ maplegend: Rocks
1313
exits:
1414
southeast:
1515
roomid: 319
16-
items:
17-
- itemid: 10016
1816
idlemessages:
1917
- A gust of wind sends a chill throgh the air.
2018
- A large wave crashes against the shore.

_datafiles/world/default/rooms/frostfang/21.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ exits:
1818
roomid: 22
1919
west:
2020
roomid: 20
21-
stash:
22-
- itemid: 10001
2321
spawninfo:
2422
- mobid: 1
2523
message: A rat scurries out from a dark hole and wiggles its whiskers.

_datafiles/world/default/rooms/frostfang/269.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ biome: house
1313
exits:
1414
south:
1515
roomid: 259
16-
items:
17-
- itemid: 26
1816
spawninfo:
1917
- mobid: 26
2018
levelmod: 10

_datafiles/world/default/rooms/frostfang/433.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ exits:
1515
roomid: 111
1616
west:
1717
roomid: 166
18-
items:
19-
- itemid: 5
2018
spawninfo:
2119
- itemid: 5
2220
respawnrate: 1 real day

0 commit comments

Comments
 (0)