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 » 08 Sep 2011, 10:15

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.
0 x

User avatar
koshi
Lobby Developer
Posts: 1058
Joined: 14 Aug 2007, 16:15

Re: Unitsync.dll, about function

Post by koshi » 08 Sep 2011, 10:37

0 x

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

Re: Unitsync.dll, about function

Post by danil_kalina » 08 Sep 2011, 13:18

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"
0 x

User avatar
koshi
Lobby Developer
Posts: 1058
Joined: 14 Aug 2007, 16:15

Re: Unitsync.dll, about function

Post by koshi » 08 Sep 2011, 13:31

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.
0 x

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

Re: Unitsync.dll, about function

Post by danil_kalina » 08 Sep 2011, 23:33

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.
0 x

Andrej
Posts: 176
Joined: 13 Aug 2006, 18:55

Re: Unitsync.dll, about function

Post by Andrej » 09 Sep 2011, 00:52

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.
0 x

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

Re: Unitsync.dll, about function

Post by danil_kalina » 28 Oct 2011, 23:46

GetSides
GetSideName(int side)

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

abma
Spring Developer
Posts: 3540
Joined: 01 Jun 2009, 00:08

Re: Unitsync.dll, about function

Post by abma » 13 Jan 2012, 15:14

(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.
0 x

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

Re: Unitsync.dll, about function

Post by danil_kalina » 13 Jan 2012, 16:17

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 ?
0 x

User avatar
koshi
Lobby Developer
Posts: 1058
Joined: 14 Aug 2007, 16:15

Re: Unitsync.dll, about function

Post by koshi » 13 Jan 2012, 16:30

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.
0 x

User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10201
Joined: 24 Jan 2006, 21:12

Re: UnitSync :: about function

Post by PicassoCT » 13 Jan 2012, 19:33

Yeah, yeah.. its always them gamedevs fault.
:P
0 x

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

Re: Unitsync.dll, about function

Post by danil_kalina » 03 Feb 2012, 14:42

koshi wrote:Uhm, are you not aware of spring's vfs? Or is that what you mean?
Not aware of VFS
0 x

Axiomatic
Posts: 68
Joined: 20 Jan 2011, 04:17

Re: Unitsync.dll, about function

Post by Axiomatic » 04 Feb 2012, 04:56

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.
0 x

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

Re: UnitSync :: about function

Post by danil_kalina » 04 Feb 2012, 11:28

Thanks a lot. Very nice example :roll:
0 x

Post Reply

Return to “Lobby Clients & Server”