What's the point of map:map type if load_map() messes it up?

new topic     » topic index » view thread      » older message » newer message

I have

map:map new_game = map:load_map( filename & ".cgm" ) 

but if map:load_map() returns -1 (due to file not existing), I get a type error (type_check failure, new_game is -1). So, the definition of type map is useless! Do I have to resort to this:

map:map new_game 
object maybe_a_map_maybe_not = map:load_map( filename & ".cgm" ) 
 
if map:map( maybe_a_map_maybe_not ) then 
  new_game = maybe_a_map_maybe_not 
else 
  msg( "No saved games. Start a new game." ) 
end if 

Maybe if load_map() fails we can return an empty map (which is not accurate, but better than failing)? or in the type definition we include the possibility that map:map can be -1?

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu