Mysterious C++/SDL error

Tools, assembly, and file formats.
Post Reply
Draik
Posts: 117
Joined: Sat Jul 26, 2008 8:52 am
Contact:

Mysterious C++/SDL error

Post by Draik »

Right, so I'm writing a Crystal Caves level editor, and it's written in C++ using SDL (Win32 with MinGW, in case it helps). And for some reason it won't compile this perfectly reasonable line of code:

Code: Select all

screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE)
I'm using the latest version of SDL. It comes out with

Code: Select all

D:\Stuff\ccleved\main.cpp:17: error: expected primary-expression before '=' token
D:\Stuff\ccleved\main.cpp:17: error: expected primary-expression before ',' token
about 3 times, finishing with

Code: Select all

D:\Stuff\ccleved\main.cpp:17: error: expected `;' before ')' token
That's the offending line of code above. I haven't missed any closing brackets or semicolons on previous lines, and screen is a pointer to an SDL_Surface. What the heck is wrong?
User avatar
CommanderSpleen
Posts: 1017
Joined: Sun Aug 31, 2003 12:11 pm
Location: The Land of Sparkly Things
Contact:

Post by CommanderSpleen »

How is that screen variable defined? I deal with Allegro, so SDL is outside of my experience.

You are missing a semicolon at the end of the statement. But the rest looks fine. The screen part at the beginning seems to be the problem. Are you sure you need to apply the return value of SDL_SetVideoMode to it?
Draik
Posts: 117
Joined: Sat Jul 26, 2008 8:52 am
Contact:

Post by Draik »

Well, it's not the semicolon. But yes, SDL_SetVideoMode returns a pointer to an SDL_Surface. I'll just rewrite the code from scratch, and see if that fixes it. :P
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

Interesting. I take it you found the level data. However, since it's in the executable, does this mean all the levels cannot be larger in size than the originals, or did you find a way around this?
KeenRush
Patch Maker
Posts: 1988
Joined: Sun Aug 31, 2003 2:52 pm
Location: Sand Yego
Contact:

Post by KeenRush »

I think every level in CC has the exactly same size -- I don't think the dimensions even can be changed.

By the way, it's about time there'll be an editor for this game, definitely going to use it. :)
Draik
Posts: 117
Joined: Sat Jul 26, 2008 8:52 am
Contact:

Post by Draik »

lemm found it, the discussion page for CC at the ModdingWiki has his findings. And yeah, the dimensions are fixed (as in, unchangeable, not hacked so we can change level size).
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

Aaah, I see now. So the levels are uncompressed and of a fixed size, which would make editing easier. I was worried they would be compressed or of variable size, which would mean there was a 'limit' you couldn't exceed.

I would be interested in the progress of this project. I have coded a small program to edit the fullscreen images, which I haven't seen anywhere else if you want to add that to your editor code (The modding wiki has the PCX format now.) which should allow full graphical modding now.
gerstrong
Posts: 63
Joined: Sun Jan 25, 2009 3:21 pm

Re: Mysterious C++/SDL error

Post by gerstrong »

Draik wrote:Right, so I'm writing a Crystal Caves level editor, and it's written in C++ using SDL (Win32 with MinGW, in case it helps). And for some reason it won't compile this perfectly reasonable line of code:

Code: Select all

screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE)
I'm using the latest version of SDL. It comes out with

Code: Select all

D:\Stuff\ccleved\main.cpp:17: error: expected primary-expression before '=' token
D:\Stuff\ccleved\main.cpp:17: error: expected primary-expression before ',' token
about 3 times, finishing with

Code: Select all

D:\Stuff\ccleved\main.cpp:17: error: expected `;' before ')' token
That's the offending line of code above. I haven't missed any closing brackets or semicolons on previous lines, and screen is a pointer to an SDL_Surface. What the heck is wrong?
Guess I come too late with that, but if you ask me, it's the missing semicolon at the end. Maybe you can show me the source code. I have good knowledge about SDL.
Post Reply