In my never ending quest to make Conquest! better, I often go back and look at old code, that is code I haven't looked at in a very long time. Sometimes I will find code that was bolted on and isn't very good (either inefficient or just written poorly). While researching a new idea (allowing players to specify when Housekeeping (HK) occurs for their kingdoms) I discovered some of this poor written code.
I didn't implement the feature, but I decided to fix the code, which was related to New Year HKs. The one line of code which caused the disaster was using the memset() function. As it's name implies, memset is used to specify what value a block of memory should have. One of the things which occurs during a NYHK is to clear the retaliation list. Retaliation allows higher level players who have been attacked by lower level players to attack back, regardless of the level difference. This was to counter low level players attacking higher level players without risk, either to wear them down or to "spy" on their army. Instead of specifying the part of the player data model dealing with retaliation, I specified the address of the whole structure. When the NYHK ran, it cleared the first 256 bytes of the player record! This may not seem like a lot (and it really isn't) but it had the effect of wiping out several key pieces of information for every player in the game. Through coding and liberal use of the reset command I was able to fix most of it (after about 3 hours), though player badges and total battles won/lost, total troops killed/lost were reset back to zero. New this week are some new random events: wandering spy, finding magical items, losing a ship. Additionally, finding troops or ships now includes a wider range (instead of just Soldiers or Barges). I also set a minimum number for movement points (MPs): players levels 1-3 receive the same amount. This was done to help lower level players do more each HK. I also increased the MP cap and removed the 50% penalty for stockpiling MPs. Finally, I redid part of the weather system. Nothing like spending time on Google figuring out how fog works...
0 Comments
Leave a Reply. |
AuthorJames has been working on Conquest! since 1993. Archives
December 2024
Categories |