Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix navfile generation #61

Merged
merged 3 commits into from
Oct 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions csgo/addons/sourcemod/scripting/ckSurf.sp
Original file line number Diff line number Diff line change
Expand Up @@ -815,9 +815,14 @@ public void OnMapStart()

// Get mapname
GetCurrentMap(g_szMapName, 128);

// create nav file
CreateNavFile();

// Load spawns
if (!g_bRenaming && !g_bInTransactionChain)
checkSpawnPoints();

// Workshop fix
char mapPieces[6][128];
int lastPiece = ExplodeString(g_szMapName, "/", mapPieces, sizeof(mapPieces), sizeof(mapPieces[]));
Expand Down Expand Up @@ -2066,9 +2071,6 @@ public void OnPluginStart()
//button sound hook
//AddNormalSoundHook(NormalSHook_callback);

//nav files
CreateNavFiles();

// Botmimic 2
// https://forums.alliedmods.net/showthread.php?t=180114
// Optionally setup a hook on CBaseEntity::Teleport to keep track of sudden place changes
Expand Down
27 changes: 11 additions & 16 deletions csgo/addons/sourcemod/scripting/ckSurf/misc.sp
Original file line number Diff line number Diff line change
Expand Up @@ -2669,31 +2669,26 @@ public void LoadInfoBot()
}
}

public void CreateNavFiles()
public void CreateNavFile()
{
char DestFile[256];
char SourceFile[256];
// check if source file exists
char SourceFile[128];
Format(SourceFile, sizeof(SourceFile), "maps/replay_bot.nav");
if (!FileExists(SourceFile))
{
LogError("<ckSurf> Failed to create .nav files. Reason: %s doesn't exist!", SourceFile);
return;
}
char map[256];
int mapListSerial = -1;
if (ReadMapList(g_MapList, mapListSerial, "mapcyclefile", MAPLIST_FLAG_CLEARARRAY | MAPLIST_FLAG_NO_DEFAULT) == null)
if (mapListSerial == -1)
return;

for (int i = 0; i < GetArraySize(g_MapList); i++)
// build nav file path
char DestFile[128];
Format(DestFile, 128, "maps/%s.nav", g_szMapName);

// copy if doesn't exist and reload via changelevel
if(!FileExists(DestFile))
{
GetArrayString(g_MapList, i, map, sizeof(map));
if (map[0])
{
Format(DestFile, sizeof(DestFile), "maps/%s.nav", map);
if (!FileExists(DestFile))
File_Copy(SourceFile, DestFile);
}
File_Copy(SourceFile, DestFile);
ForceChangeLevel(g_szMapName, ".nav file generate");
}
}

Expand Down
Binary file modified csgo/maps/replay_bot.nav
Binary file not shown.