UnitSync :: about function
Moderators: Moderators, Lobby Developers
- danil_kalina
- Posts: 505
- Joined: 08 Feb 2010, 22:21
UnitSync :: about function
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 ???
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.
- danil_kalina
- Posts: 505
- Joined: 08 Feb 2010, 22:21
Re: Unitsync.dll, about function
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"
GetPrimaryModIndex(const char* name)
For all downloaded maps "GetMapArchiveCount" returns "2"
For nonexistent maps "GetMapArchiveCount" returns "1"
Re: Unitsync.dll, about function
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.
- danil_kalina
- Posts: 505
- Joined: 08 Feb 2010, 22:21
Re: Unitsync.dll, about function
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.
I thought of a such way. so no other way exists I think.
Re: Unitsync.dll, about function
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:
So I assume it's not very fast.
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;
}
}
- danil_kalina
- Posts: 505
- Joined: 08 Feb 2010, 22:21
Re: Unitsync.dll, about function
GetSides
GetSideName(int side)
How we could retrieve Icon for side(faction) ?
Icon for ARM and CORE
GetSideName(int side)
How we could retrieve Icon for side(faction) ?
Icon for ARM and CORE
Re: Unitsync.dll, about function
(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.
this should help:
http://springrts.com/wiki/Mod_Development:Sidepics
and maybe http://answers.springlobby.info/ is a better place for such questions.
- danil_kalina
- Posts: 505
- Joined: 08 Feb 2010, 22:21
Re: Unitsync.dll, about function
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 ?
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 ?
Re: Unitsync.dll, about function
Uhm, are you not aware of spring's vfs? Or is that what you mean?danil_kalina wrote:have to extract the game
SpringLobby has been supporting png for a very long time, it's up to the game dev to actually use png.danil_kalina wrote:but the icon is in .bmp format and also not fully transparent, WTF ?
why not .png ?
Re: UnitSync :: about function
Yeah, yeah.. its always them gamedevs fault.
- danil_kalina
- Posts: 505
- Joined: 08 Feb 2010, 22:21
Re: Unitsync.dll, about function
Not aware of VFSkoshi wrote:Uhm, are you not aware of spring's vfs? Or is that what you mean?
Re: Unitsync.dll, about function
Here's a simple example without error checking.danil_kalina wrote:Not aware of VFS
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);
- danil_kalina
- Posts: 505
- Joined: 08 Feb 2010, 22:21
Re: UnitSync :: about function
Thanks a lot. Very nice example