Conquest! - Free Real-Time Strategy Game
  • Home
  • Start Playing
  • How to Play
  • About
    • Development Blog
    • History
    • Press Kit
    • Server Change Log
    • World Events
  • Login Help
  • Contact Us
  • Privacy Policy

Memset or How I Corrupted Player Records

6/13/2015

0 Comments

 
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.

    Author

    James has been working on Conquest! since 1993.

    Archives

    April 2025
    December 2024
    June 2024
    December 2023
    August 2023
    September 2022
    July 2022
    October 2021
    September 2021
    April 2021
    September 2020
    February 2017
    December 2016
    October 2016
    September 2016
    August 2016
    July 2016
    May 2016
    April 2016
    March 2016
    February 2016
    January 2016
    December 2015
    November 2015
    October 2015
    September 2015
    August 2015
    July 2015
    June 2015
    May 2015

    Categories

    All

    RSS Feed

Copyright 2025 GreenLion Gaming All Rights Reserved
  • Home
  • Start Playing
  • How to Play
  • About
    • Development Blog
    • History
    • Press Kit
    • Server Change Log
    • World Events
  • Login Help
  • Contact Us
  • Privacy Policy