View topic - UnitSync :: about function



All times are UTC + 1 hour


Post new topic Reply to topic  [ 14 posts ] 
Author Message
PostPosted: 08 Sep 2011, 09:15 
Lobby Developer
User avatar

Joined: 08 Feb 2010, 22:21
Location: Saint-Petersburg, Russia
Where could I find out more information about functions in that library ?

I need a function that returns the state of map's existence.
GetMapArchiveCount ???


Last edited by danil_kalina on 13 Jan 2012, 16:21, edited 1 time in total.

Top
 Offline Profile  
 
PostPosted: 08 Sep 2011, 09:37 
Lobby Developer
User avatar

Joined: 14 Aug 2007, 15:15
https://github.com/spring/spring/blob/m ... sync_api.h


Top
 Offline Profile  
 
PostPosted: 08 Sep 2011, 12:18 
Lobby Developer
User avatar

Joined: 08 Feb 2010, 22:21
Location: Saint-Petersburg, Russia
We do have a such function for Mods, but for Maps doesn't:
GetPrimaryModIndex(const char* name)

For all downloaded maps "GetMapArchiveCount" returns "2"
For nonexistent maps "GetMapArchiveCount" returns "1"


Top
 Offline Profile  
 
PostPosted: 08 Sep 2011, 12:31 
Lobby Developer
User avatar

Joined: 14 Aug 2007, 15:15
You're not making much sense to me. I suggest you read the api docs again or maybe have a look at one of the unitsync users like SpringLobby or Tasclient.


Top
 Offline Profile  
 
PostPosted: 08 Sep 2011, 22:33 
Lobby Developer
User avatar

Joined: 08 Feb 2010, 22:21
Location: Saint-Petersburg, Russia
SpringLobby loads "MapNameList" and "ModNameList" through iterating all the maps and mods. If we want to find any map we just need to verify it in the list.
I thought of a such way. so no other way exists I think.


Top
 Offline Profile  
 
PostPosted: 08 Sep 2011, 23:52 

Joined: 13 Aug 2006, 17:55
I think you can check for existence of a single map like this:

If you get a '0' return value from calling GetMapInfo with the map's name and GetNextError returns a string starting with "Could not find a map" after the call, that means the map doesn't exist.
(See the 'throw' statement in GetMapFile inside unitsync.cpp for the exact wording on error message)

The way the check is implemented internally in ArchiveScanner is by iterating through all maps:
Code:
   for (std::map<std::string, ArchiveInfo>::const_iterator aii = archiveInfo.begin(); aii != archiveInfo.end(); ++aii) {
      if (s == aii->second.archiveData.name) {
         return aii->second.archiveData.mapfile;
      }
   }

So I assume it's not very fast.


Top
 Offline Profile  
 
PostPosted: 28 Oct 2011, 22:46 
Lobby Developer
User avatar

Joined: 08 Feb 2010, 22:21
Location: Saint-Petersburg, Russia
GetSides
GetSideName(int side)

How we could retrieve Icon for side(faction) ?
Icon for ARM and CORE


Top
 Offline Profile  
 
PostPosted: 13 Jan 2012, 15:14 
Spring Developer

Joined: 31 May 2009, 23:08
(i know its an old thread, but the question is still unanswerd)

this should help:
http://springrts.com/wiki/Mod_Development:Sidepics



and maybe http://answers.springlobby.info/ is a better place for such questions.


Top
 Offline Profile  
 
PostPosted: 13 Jan 2012, 16:17 
Lobby Developer
User avatar

Joined: 08 Feb 2010, 22:21
Location: Saint-Petersburg, Russia
thanks
have to extract the game, then take pictures. not good, but it is ok.

but the icon is in .bmp format and also not fully transparent, WTF ?
why not .png ?


Top
 Offline Profile  
 
PostPosted: 13 Jan 2012, 16:30 
Lobby Developer
User avatar

Joined: 14 Aug 2007, 15:15
danil_kalina wrote:
have to extract the game
Uhm, are you not aware of spring's vfs? Or is that what you mean?

danil_kalina wrote:
but the icon is in .bmp format and also not fully transparent, WTF ?
why not .png ?
SpringLobby has been supporting png for a very long time, it's up to the game dev to actually use png.


Top
 Offline Profile  
 
PostPosted: 13 Jan 2012, 19:33 
Journeywar Developer & Mapper
User avatar

Joined: 24 Jan 2006, 21:12
Location: There is no god - and reality is his prophetess
Yeah, yeah.. its always them gamedevs fault.
:P


Top
 Offline Profile  
 
PostPosted: 03 Feb 2012, 14:42 
Lobby Developer
User avatar

Joined: 08 Feb 2010, 22:21
Location: Saint-Petersburg, Russia
koshi wrote:
Uhm, are you not aware of spring's vfs? Or is that what you mean?

Not aware of VFS


Top
 Offline Profile  
 
PostPosted: 04 Feb 2012, 04:56 

Joined: 20 Jan 2011, 04:17
danil_kalina wrote:
Not aware of VFS


Here's a simple example without error checking.
Code:

//load mod
const char *modName = "Balanced Annihilation V7.63";
Init();
GetPrimaryModCount();
int modIndex = GetPrimaryModIndex(modName);
GetPrimaryModArchiveCount(modIndex);
AddAllArchives(GetPrimaryModArchive(modIndex));


const char *sidePath = "SidePics/ARM.png";
int fd = OpenFileVFS(sidePath);
if (!fd) {
   sidePath =  "SidePics/ARM.bmp";
   fd = OpenFileVFS(vfsPath);
}
size_t fileSize = FileSizeVFS(fd);
uint8_t buff[fileSize];
ReadFileVFS(fd, buff, sizeof(buff));
CloseFileVFS(fd);


The sidepic can be BMP or PNG. If its BMP then white is used for transparency.


Top
 Offline Profile  
 
PostPosted: 04 Feb 2012, 11:28 
Lobby Developer
User avatar

Joined: 08 Feb 2010, 22:21
Location: Saint-Petersburg, Russia
Thanks a lot. Very nice example :roll:


Top
 Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group

Site layout created by Roflcopter et al.