Server coding question. Please help!

Can you help improve your favourite game? Hardcore C mages, talented artists, and players with any level of experience are welcome!
Post Reply
Lexxie
Veteran
Posts: 127
Joined: Fri Jun 23, 2017 4:18 pm

Server coding question. Please help!

Post by Lexxie »

For freeciv server I am trying to construct a line of code to check an if(condition), but cannot figure out how.

Here is the pseudo-code for what I'm trying:

if ( (tile_get_known(ptile, pplayer) == TILE_KNOWN_UNSEEN)
&& (player_thinks_there_is_a_nonallied_city_on_the_fogged_tile(pplayer,ptile) ) {
/* stuff goes here */
}

How would I do the "player_believes_there_is_a_nonallied_city_on_the_fogged_tile(pplayer,ptile)" ?

In other words, how do I check if a player sees a non-allied city on a fogged tile. This can be a different truth value from whether there actually is a non-allied city there, because on a fog-of-war tile, maybe the city was destroyed, disbanded, or conquered by an ally who doesn't share vision.

Thank you in advance if you know the answer. I think it has something to do with map_get_player_city() but can't figure it out.

Cheers
cazfi
Elite
Posts: 3077
Joined: Tue Jan 29, 2013 6:54 pm

Re: Server coding question. Please help!

Post by cazfi »

Lexxie wrote: Sun Oct 30, 2022 10:04 amI think it has something to do with map_get_player_city() but can't figure it out.
Should be as easy as checking if the returned vision_site is a city (I guess you have to check "identity > 0", as there's no API for that), and owned ( vision_site_owner() ) by someone non-allied.
Lexxie
Veteran
Posts: 127
Joined: Fri Jun 23, 2017 4:18 pm

Re: Server coding question. Please help!

Post by Lexxie »

Thank you for quick response!! :)
Post Reply