Skip to content

Commit

Permalink
Merge pull request #406 from alliedmodders/findmap17
Browse files Browse the repository at this point in the history
Change FindMap to take a const char* for searching instead of char* (r=Drifter).
  • Loading branch information
KyleSanderson committed Sep 12, 2015
2 parents bd6e1d0 + 2703a29 commit 038a5f9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
21 changes: 17 additions & 4 deletions core/smn_halflife.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,23 @@ static cell_t FindMap(IPluginContext *pContext, const cell_t *params)
{
char *pMapname;
pContext->LocalToString(params[1], &pMapname);

cell_t size = params[2];

return static_cast<cell_t>(g_HL2.FindMap(pMapname, size));

cell_t len;
if (params[0] > 2)
{
len = params[3];

char *pDestMap;
pContext->LocalToString(params[2], &pDestMap);
strncpy(pDestMap, pMapname, len);
pMapname = pDestMap;
}
else
{
len = params[2];
}

return static_cast<cell_t>(g_HL2.FindMap(pMapname, len));
}

static cell_t IsDedicatedServer(IPluginContext *pContext, const cell_t *params)
Expand Down
7 changes: 4 additions & 3 deletions plugins/include/halflife.inc
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,13 @@ native bool:IsMapValid(const String:map[]);
* Returns whether a full or partial map name is found or can be resolved
*
* @param map Map name (usually same as map path relative to maps/ dir,
* excluding .bsp extension). If result is FindMap_FuzzyMatch
* or FindMap_NonCanonical, this will be updated to the full path.
* excluding .bsp extension).
* @param foundmap Resolved map name. If the return is FindMap_FuzzyMatch
* or FindMap_NonCanonical the buffer will be the full path.
* @param maxlen Maximum length to write to map var.
* @return Result of the find operation. Not all result types are supported on all games.
*/
native FindMapResult FindMap(char[] map, int maxlen);
native FindMapResult FindMap(const char[] map, char[] foundmap, int maxlen);

/**
* Returns whether the server is dedicated.
Expand Down

0 comments on commit 038a5f9

Please sign in to comment.