UnitSync :: about function

UnitSync :: about function

Discuss development of lobby clients, server, autohosts and auto-download software.

Moderators: Moderators, Lobby Developers

Post Reply
User avatar
danil_kalina
Posts: 505
Joined: 08 Feb 2010, 22:21

UnitSync :: about function

Post by danil_kalina »

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.
User avatar
danil_kalina
Posts: 505
Joined: 08 Feb 2010, 22:21

Re: Unitsync.dll, about function

Post by danil_kalina »

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"
User avatar
koshi
Lobby Developer
Posts: 1059
Joined: 14 Aug 2007, 16:15

Re: Unitsync.dll, about function

Post by koshi »

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.
User avatar
danil_kalina
Posts: 505
Joined: 08 Feb 2010, 22:21

Re: Unitsync.dll, about function

Post by danil_kalina »

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.
Andrej
Posts: 176
Joined: 13 Aug 2006, 18:55

Re: Unitsync.dll, about function

Post by Andrej »

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: Select all

	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.
User avatar
danil_kalina
Posts: 505
Joined: 08 Feb 2010, 22:21

Re: Unitsync.dll, about function

Post by danil_kalina »

GetSides
GetSideName(int side)

How we could retrieve Icon for side(faction) ?
Icon for ARM and CORE
abma
Spring Developer
Posts: 3798
Joined: 01 Jun 2009, 00:08

Re: Unitsync.dll, about function

Post by abma »

(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.
User avatar
danil_kalina
Posts: 505
Joined: 08 Feb 2010, 22:21

Re: Unitsync.dll, about function

Post by danil_kalina »

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 ?
User avatar
koshi
Lobby Developer
Posts: 1059
Joined: 14 Aug 2007, 16:15

Re: Unitsync.dll, about function

Post by koshi »

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.
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10450
Joined: 24 Jan 2006, 21:12

Re: UnitSync :: about function

Post by PicassoCT »

Yeah, yeah.. its always them gamedevs fault.
:P
User avatar
danil_kalina
Posts: 505
Joined: 08 Feb 2010, 22:21

Re: Unitsync.dll, about function

Post by danil_kalina »

koshi wrote:Uhm, are you not aware of spring's vfs? Or is that what you mean?
Not aware of VFS
Axiomatic
Posts: 68
Joined: 20 Jan 2011, 04:17

Re: Unitsync.dll, about function

Post by Axiomatic »

danil_kalina wrote:Not aware of VFS
Here's a simple example without error checking.

Code: Select all


//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.
User avatar
danil_kalina
Posts: 505
Joined: 08 Feb 2010, 22:21

Re: UnitSync :: about function

Post by danil_kalina »

Thanks a lot. Very nice example :roll:
Post Reply

Return to “Lobby Clients & Server”