Yeah iterating the entire world object list isn't very practical, but for now it's faster than what was there and some bugs are fixed so I'm happy with it for now. I've had a look around the forums for the whole server objects map thing but not sure I really understand how it works. Basically if the server I'm working on doesn't currently use it I don't know about it. Something else to add to the list of things to learn about
It'd be a lot easier to implement that if this source had any semblance of storing all related information in the same place, but sadly it doesn't. It's not like it would be unreasonable to store a base time and then calculate actual time based on player count. Old logic was as follows:
The entire thing being such a clusterfuck right now would have meant a complete rewrite of the world object manager which is too closely tied to many other classes such as skills and therefore would also have required a rewrite (ad infinitum, at least until I've rewritten the whole thing from scratch). Having this separation of responsibility is an improvement in the long run IMO and will make it easier to make further changes down the line.
Take the ThievingData class as it is right now for example.
Code:
protected static int[][] NPCS = {
new int[] {1, 2, 3, 7875, 7877, 7879}, // Men.
new int[] {4, 5, 6, 7881, 7883}, // Women.
new int[] {7}, // Farmer.
new int[] {1715}, // Female HAM members.
new int[] {1716}, // Male HAM members.
new int[] {15}, // Warrior
new int[] {187}, // Rogue
//Cave goblin here (no need for them in an RSPS..)
new int[] {2234}, // Master farmer.
new int[] {9, 32, 296, 297, 298, 299}, // Guard.
//'Fremmenik' here
new int[] {6174, 1880}, // Bandit guard.
new int[] {1926, 1931}, // Desert bandits.
new int[] {23, 26}, // Knights
new int[] {34}, // Watchman
//Menaphite thug here.
new int[] {20}, // Paladin
new int[] {66, 67, 68}, // Gnomes.
new int[] {21}, // Hero.
new int[] {2363, 2364, 2365, 2366, 2367}, // Elf
};
protected static int[] NPC_LVL = {
1, // Men.
1, // Women.
10, // Farmer.
15, // Female HAM.
20, // Male HAM.
25, // Warrior.
32, // Rogue.
38, // Master farmer.
40, // Guard.
45, // Bandit guard.
53, // Desert bandits.
55, // Knights.
65, // Watchman.
70, // Paladin.
75, // Gnome.
80, // Hero.
85, // Elf.
};
protected static int[][] NPC_REWARD = {
new int[] {995}, // Men.
new int[] {995}, // Women.
new int[] {995, 5318}, // Farmer
new int[] {4298, 4300, 4302, 4304, 4306, 4308, 4310, 1511, 688, 689, 687, 686, 1605, 314, 946, 995, 1267, 371, 199, 453, 444, 201, 203, 205, 175, 884, 2138, 385}, // Female H.A.M TODO - lvl 1 clue
new int[] {4298, 4300, 4302, 4304, 4306, 4308, 4310, 1511, 688, 689, 687, 686, 1605, 314, 946, 995, 1267, 371, 199, 453, 444, 201, 203, 205, 175, 884, 2138, 385}, // Male H.A.M TODO - lvl 1 clue
new int[] {995}, // Warrior
new int[] {995, 1523, 954, 554, 555, 556, 175}, // Rogue
new int[] {5318, 5319, 5320, 5321, 5322, 5323, 5324, 5305, 5306, 5307, 5308, 5309, 5310, 5311, 5096, 5097, 5098, 5099, 5100, 5101, 5102, 5103, 5104, 5105, 5106}, // Master farmer.
new int[] {995}, // Guard
new int[] {995, 175, 1523, 1823}, // Bandit guard
new int[] {995, 175, 1523, 1823}, // Bandits
new int[] {995}, // Knight
new int[] {995, 2309}, // Watchman
new int[] {995, 562}, // Paladin
new int[] {995, 2357, 561}, // Gnome
new int[] {995}, // Hero
new int[] {995}, // Elf
};
protected static int[][] NPC_REWARD_AMOUNT = {
new int[] {35}, // Men.
new int[] {35}, // Women.
new int[] {150, 1}, // Farmer
new int[] {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 6000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100, 1, 1}, // Female H.A.M
new int[] {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 6000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100, 1, 1}, // Male H.A.M
new int[] {300}, // Warrior
new int[] {500, 1, 1, 10, 10, 10, 1}, // Rogue
new int[] {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, // Master farmer.
new int[] {500}, // Guard
new int[] {400, 1, 1, 1}, // Bandit guard
new int[] {340, 1, 1, 1}, // Bandit
new int[] {550, 1}, // Knight
new int[] {600, 1}, // Watchman
new int[] {750, 5}, // Paladin
new int[] {900, 1, 2}, // Gnome
new int[] {1100}, // Hero
new int[] {1500}, // Elf
};
protected static double[] NPC_XP = {
8, // Men & women.
8, // Women.
14.5, // Farmer.
18.5, // Female HAM.
22.5, // Male HAM.
26, // Warrior.
35.5, // Rogue.
43, // Master farmer.
46.8, // Guard.
65, // Bandit guard.
79.4, // Desert bandit.
84.3, // Knights.
137.5, // Watchman.
151.75, // Paladin.
198.5, // Gnome.
275, // Hero
353 // Elf
};
All of this should be stored together in SomeClass which contains IDs of NPCs, XP they give and so on. But unfortunately it's all stored separately and iterated over in its entirety. When this comes to a point where related data is stored together (and I'll probably store it on disk as well, hardcoded values in memory are meh) it'll be a lot easier to remove unnecessary information.