The Dink Network

Reply to Re: DFArc3 beta-testing

If you don't have an account, just leave the password field blank.
Username:
Password:
Subject:
Antispam: Enter Dink Smallwood's last name (surname) below.
Formatting: :) :( ;( :P ;) :D >( : :s :O evil cat blood
Bold font Italic font hyperlink Code tags
Message:
 
 
October 16th 2014, 05:13 AM
farmer.gif
Beuc
Peasant He/Him France
 
Hmmm:
  /* If running the game, fallback to the default hard.dat, but if
     running the editor, recreate it in all cases. */
  if (f == NULL && !dinkedit)
    f = paths_fallbackfile_fopen("hard.dat", "rb");

  if (f == NULL)
    {
      //make new data file
      memset(&hmap, 0, sizeof(struct hardness));
      save_hard();
      return;
    }


(that comes back from 1.07, let's have a nostalgia moment reading the old code
    if (!dinkedit)
    {
        if (!exist(crap)) sprintf(crap, "..\\dink\\hard.dat");
    }

    fp = fopen(crap, "rb");
    if (!fp)
    {
        //fclose(fp);
        fp = fopen(crap, "wb");
        //make new data file
        ZeroMemory(&hmap, sizeof(struct hardness));     
        fwrite(&hmap,sizeof(struct hardness),1,fp);
        fclose(fp);
    }

)

I suppose your problem happened when WDE2 read/wrote hard.dat just when the Dink was trying to read it -- under windows, where exclusive file opening doesn't seem to be so great at avoiding file corruption.

How about we ditch this "recreate a completely empty hard.dat on error" from the engine?
That doesn't seem to bring any value in the game, it only needs to be done in the editor.