Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


GameCodingNinja

Member Since 18 Aug 2005
Offline Last Active Jul 25 2015 08:53 AM

Posts I've Made

In Topic: SDL_SetWindowDisplayMode problem

29 December 2014 - 03:23 PM

Never mind. I just learned SDL doesn't allow resolution change while in full screen mode. Bah!


In Topic: Wierd compiler errors that can be fixed by removing spaces before code

18 December 2014 - 11:36 AM

Thanks for the info!


In Topic: Wierd compiler errors that can be fixed by removing spaces before code

17 December 2014 - 08:22 PM

Update: I found the problem. I need to open the file as "rb" and not "r".

 

Below is my function for loading the code file into a buffer. Something odd is going on here. I added some test code to save out the buffer.

boost::shared_array<char> FileToBuf( const std::string & file, size_t & sizeInBytes )
{
    const size_t TERMINATOR_SIZE(10);

    // Open file for reading
    NSmart::scoped_filehandle_ptr<FILE> scpFile( fopen(file.c_str(), "r") );
    if( scpFile.isNull() )
        throw NExcept::CCriticalException("File Load Error!",
            boost::str( boost::format("Error Loading file (%s).\n\n%s\nLine: %s") % file % __FUNCTION__ % __LINE__ ));

    // Seek to the end of the file to find out
    // how many bytes into the file we are and add one for temination
    fseek( scpFile.get(), 0, SEEK_END );
    sizeInBytes = ftell( scpFile.get() ) + TERMINATOR_SIZE;

    // Allocate a buffer for the entire length
    // of the file and a null termination
    boost::shared_array<char> spChar( new char[sizeInBytes] );

    // zero out the whole buffer
    std::memset(spChar.get(), 0, sizeInBytes);

    // Go back to the beginning of the file and 
    // read the contents of the file in to the buffer
    fseek( scpFile.get(), 0, SEEK_SET );
    fread( spChar.get(), sizeInBytes-TERMINATOR_SIZE, 1, scpFile.get() );

    return spChar;

}	// FileToBuf

This is the bottom of the file. It's definately not a null termination problem.

void Control_Fast_Solid_Selected( CSpriteScript2d @script )
{
    script.SetVisible( true );
    script.SetDefaultColor();

    CColor hiColor = script.GetDefaultColor();
    hiColor.TransformHSV( 0, 1, 1.3 );

    script.SetColor( hiColor );

    Hold( 100 );

    script.SetVisible( false );
}
();



    CColor hiColor = script.GetDefaultColor();

    hiColor.TransformHSV( 0, 1, 1.3 );



    script.SetColor( hiColor );



    Hold

In Topic: Wierd compiler errors that can be fixed by removing spaces before code

17 December 2014 - 12:19 PM

I spoke too soon. Further tests show std::strlen will return a number greater then 4,096. I can also solve the problem by copying that last function, pasting it at the bottom and append a number to the function name.

 

I don't think this is an AngelScript issue. Not sure what the problem is.


In Topic: Wierd compiler errors that can be fixed by removing spaces before code

17 December 2014 - 09:54 AM

Thanks for your help! I found the problem. I use my own loader but the problem is the below line of code. The file size in bytes is 4,146 but std::strlen only seems to report a number as high as 4,096. Putting zero in that same spot appears to be subject to the same problem.

if( pScriptModule->AddScriptSection(filePath.c_str(), spChar.get(), std::strlen( spChar.get() )) < 0 )

PARTNERS