Random Chitchat 2012-2016
And I'm just sitting here in my class room Wink

Have fun thereBig Grin
Thanks given by:
Well, you're sitting in your classroom browsing through MCServer forum, that's not so bad either. Back in my days we had to pay attention at schoolBig Grin
Thanks given by:
I hope you had better teachers then our math teacher, because he didn't show up.Tongue
Thanks given by:
It is supposed, that params at places like this:
Code:
    inline static void SetBiome(BiomeMap & a_BiomeMap, int a_X, int a_Z, EMCSBiome a_Biome)
    {
        ASSERT((a_X >= 0) && (a_X <= Width));
        ASSERT((a_Z >= 0) && (a_Z <= Width));
        a_BiomeMap[a_X + Width * a_Z] = a_Biome;
    }
are only checked for validity in debug mode?
I'm asking, because MSVS is giving me that warning after I run code analysis tool.
   
http://msdn.microsoft.com/en-us/library/ww5t02fa.aspx
Thanks given by:
GitHub is confusing me :O
I only want to create a pull request :/

EDIT:
I switch base and head and now its working. Smile
Thanks given by:
(08-28-2014, 06:07 PM)LO1ZB Wrote: It is supposed, that params at places like this:
Code:
    inline static void SetBiome(BiomeMap & a_BiomeMap, int a_X, int a_Z, EMCSBiome a_Biome)
    {
        ASSERT((a_X >= 0) && (a_X <= Width));
        ASSERT((a_Z >= 0) && (a_Z <= Width));
        a_BiomeMap[a_X + Width * a_Z] = a_Biome;
    }
are only checked for validity in debug mode?
I'm asking, because MSVS is giving me that warning after I run code analysis tool.

http://msdn.microsoft.com/en-us/library/ww5t02fa.aspx

Yes, the ASSERT macro is emptied in Release builds.

That's a good point though, what if something tries to write to a_BiomeMap[16 + Width * 16] (a_BiomeMap[272])?
Thanks given by:
The asserts seem wrong, the comparison to Width should not include equality.
Does VS give you any more information on this particular warning, such as the steps required to reproduce it?
Thanks given by:
(08-28-2014, 09:05 PM)xoft Wrote: The asserts seem wrong, the comparison to Width should not include equality.
Does VS give you any more information on this particular warning, such as the steps required to reproduce it?
Not for this one. (1 of 32 read/write overflow warnings)
But I think i know what the problem is.
ChunkDev.h line 78
Code:
typedef EMCSBiome BiomeMap[Width * Width];
the leght of BiomMap is 256 -> index 0-255
Code:
    inline static void SetBiome(BiomeMap & a_BiomeMap, int a_X, int a_Z, EMCSBiome a_Biome)
    {
        ASSERT((a_X >= 0) && (a_X <= Width));
        ASSERT((a_Z >= 0) && (a_Z <= Width));
        a_BiomeMap[a_X + Width * a_Z] = a_Biome;
    }
if a_X and a_Z are 16
a_X + Width * a_Z = 16 + 256 = 272
This would corret the warning:
Code:
    inline static void SetBiome(BiomeMap & a_BiomeMap, int a_X, int a_Z, EMCSBiome a_Biome)
    {
        VERIFY((a_X >= 0) && (a_X <= Width));
        VERIFY((a_Z >= 0) && (a_Z <= Width));
        a_BiomeMap[(a_X * a_Z) - 1 ] = a_Biome;
    }
Thanks given by:
Your change may correct the warning, but it's the wrong code. You need to keep the index calculation as is, and change only the condition inside the ASSERTs, from "a_X <= Width" to "a_X < Width"; if the warning stays, then someone's calling the function wrong and we have to find the bad caller.
Thanks given by:
Well.. my school wants everyone to buy their own domain so they can eventualy upload their website on it. Any suggestions?Tongue
Thanks given by:




Users browsing this thread: 23 Guest(s)