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

multiple zones #513

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/surftimer/api.sp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public int Native_GetMapStages(Handle plugin, int numParams)
{
int stages = 0;
if (g_bhasStages)
stages = g_mapZonesTypeCount[0][3] + 1;
stages = g_TotalStages;
return stages;
}

Expand Down
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/surftimer/buttonpress.sp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ public void CL_OnEndTimerPress(int client)
g_fCheckpointTimesNew[zGroup][client][g_TotalStages-1] = g_fFinalTime[client];
else
g_fCheckpointTimesNew[zGroup][client][g_iTotalCheckpoints] = g_fFinalTime[client];

g_fPBDifference[client][0] = g_fFinalTime[client] - g_fPersonalRecord[client];
g_fWRDifference[client][0] = g_fFinalTime[client] - g_fRecordMapTime;

Expand Down
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/surftimer/commands.sp
Original file line number Diff line number Diff line change
Expand Up @@ -1410,7 +1410,7 @@ public Action Command_Restart(int client, int args)
g_bClientRestarting[client] = false;

// Check that the client has a timer running, the zonegroup he is in has stages and that this is the first click
if (IsValidClient(client) && g_bTimerRunning[client] && g_mapZonesTypeCount[g_iClientInZone[client][2]][3] > 0 && !g_bClientRestarting[client] && g_Stage[g_iClientInZone[client][2]][client] > 1)
if (IsValidClient(client) && g_bTimerRunning[client] && g_TotalStages > 0 && !g_bClientRestarting[client] && g_Stage[g_iClientInZone[client][2]][client] > 1)
{
g_fClientRestarting[client] = GetGameTime();
g_bClientRestarting[client] = true;
Expand Down
1 change: 0 additions & 1 deletion addons/sourcemod/scripting/surftimer/db/queries.sp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ char sql_createWrcps[] = "CREATE TABLE IF NOT EXISTS `ck_wrcps` (`steamid` varch
char sql_createZones[] = "CREATE TABLE `ck_zones` (`mapname` varchar(54) NOT NULL, `zoneid` int(12) NOT NULL DEFAULT '-1', `zonetype` int(12) DEFAULT '-1', `zonetypeid` int(12) DEFAULT '-1', `pointa_x` float DEFAULT '-1', `pointa_y` float DEFAULT '-1', `pointa_z` float DEFAULT '-1', `pointb_x` float DEFAULT '-1', `pointb_y` float DEFAULT '-1', `pointb_z` float DEFAULT '-1', `vis` int(12) DEFAULT '0', `team` int(12) DEFAULT '0', `zonegroup` int(11) NOT NULL DEFAULT '0', `zonename` varchar(128) DEFAULT NULL, `hookname` varchar(128) DEFAULT 'None', `targetname` varchar(128) DEFAULT 'player', `onejumplimit` int(12) NOT NULL DEFAULT '1', `prespeed` int(64) NOT NULL DEFAULT '%.1f', PRIMARY KEY (`mapname`,`zoneid`)) DEFAULT CHARSET=utf8mb4;";
char sql_insertZones[] = "INSERT INTO ck_zones (mapname, zoneid, zonetype, zonetypeid, pointa_x, pointa_y, pointa_z, pointb_x, pointb_y, pointb_z, vis, team, zonegroup, zonename, hookname, targetname, onejumplimit, prespeed) VALUES ('%s', '%i', '%i', '%i', '%f', '%f', '%f', '%f', '%f', '%f', '%i', '%i', '%i','%s','%s','%s',%i,%f)";
char sql_updateZone[] = "UPDATE ck_zones SET zonetype = '%i', zonetypeid = '%i', pointa_x = '%f', pointa_y ='%f', pointa_z = '%f', pointb_x = '%f', pointb_y = '%f', pointb_z = '%f', vis = '%i', team = '%i', onejumplimit = '%i', prespeed = '%f', hookname = '%s', targetname = '%s', zonegroup = '%i' WHERE zoneid = '%i' AND mapname = '%s'";
char sql_selectzoneTypeIds[] = "SELECT zonetypeid FROM ck_zones WHERE mapname='%s' AND zonetype='%i' AND zonegroup = '%i';";
char sql_selectMapZones[] = "SELECT zoneid, zonetype, zonetypeid, pointa_x, pointa_y, pointa_z, pointb_x, pointb_y, pointb_z, vis, team, zonegroup, zonename, hookname, targetname, onejumplimit, prespeed FROM ck_zones WHERE mapname = '%s' ORDER BY zonetypeid ASC";
char sql_selectTotalBonusCount[] = "SELECT mapname, zoneid, zonetype, zonetypeid, pointa_x, pointa_y, pointa_z, pointb_x, pointb_y, pointb_z, vis, team, zonegroup, zonename FROM ck_zones WHERE zonetype = 3 GROUP BY mapname, zonegroup;";
char sql_selectZoneIds[] = "SELECT mapname, zoneid, zonetype, zonetypeid, pointa_x, pointa_y, pointa_z, pointb_x, pointb_y, pointb_z, vis, team, zonegroup, zonename, hookname, targetname, onejumplimit, prespeed FROM ck_zones WHERE mapname = '%s' ORDER BY zoneid ASC";
Expand Down
24 changes: 12 additions & 12 deletions addons/sourcemod/scripting/surftimer/misc.sp
Original file line number Diff line number Diff line change
Expand Up @@ -2982,7 +2982,7 @@ public void SpecListMenuDead(int client) // What Spectators see
Format(szProBest, 32, "None");

if (g_bhasStages) // There are stages
Format(szStage, 32, "Stage: %i / %i", g_Stage[g_iClientInZone[ObservedUser][2]][ObservedUser], (g_mapZonesTypeCount[g_iClientInZone[ObservedUser][2]][3] + 1));
Format(szStage, 32, "Stage: %i / %i", g_Stage[g_iClientInZone[ObservedUser][2]][ObservedUser], g_TotalStages);
else
Format(szStage, 32, "Linear map");

Expand Down Expand Up @@ -3614,16 +3614,16 @@ public void CenterHudAlive(int client)
{
if (g_bSaveLocTele[client]) // Has the player teleported to saveloc?
{
Format(module[i], 128, "Stage: %i/%i", g_iPlayerPracLocationSnap[client][g_iPlayerPracLocationSnapIdClient[client]], (g_mapZonesTypeCount[g_iClientInZone[client][2]][3] + 1));
Format(module[i], 128, "Stage: %i/%i", g_iPlayerPracLocationSnap[client][g_iPlayerPracLocationSnapIdClient[client]], g_TotalStages);
}
else
{
Format(module[i], 128, "Stage: %i/%i", g_Stage[g_iClientInZone[client][2]][client], (g_mapZonesTypeCount[g_iClientInZone[client][2]][3] + 1));
Format(module[i], 128, "Stage: %i/%i", g_Stage[g_iClientInZone[client][2]][client], g_TotalStages);
}
}
else
{
Format(module[i], 128, "Stage: %i/%i", g_Stage[g_iClientInZone[client][2]][client], (g_mapZonesTypeCount[g_iClientInZone[client][2]][3] + 1)); // less \t's to make lines align
Format(module[i], 128, "Stage: %i/%i", g_Stage[g_iClientInZone[client][2]][client], g_TotalStages); // less \t's to make lines align
}
}
}
Expand Down Expand Up @@ -3816,7 +3816,7 @@ public void SideHudAlive(int client)
// Format(szStage, 64, "Linear Map");
char szCP[64];
char szCurrentCP[64];
if (g_iCurrentCheckpoint[client] == g_mapZonesTypeCount[g_iClientInZone[client][2]][4])
if (g_iCurrentCheckpoint[client] == g_iTotalCheckpoints)
{
FormatTimeFloat(0, g_fRecordMapTime, 3, szCP, 64);
Format(szCurrentCP, 64, "End Zone");
Expand Down Expand Up @@ -3853,16 +3853,16 @@ public void SideHudAlive(int client)
{
if (g_bSaveLocTele[client]) // Has the player teleported to saveloc?
{
Format(szStage, 64, "Stage: %i / %i", g_iPlayerPracLocationSnap[client][g_iLastSaveLocIdClient[client]], (g_mapZonesTypeCount[g_iClientInZone[client][2]][3] + 1));
Format(szStage, 64, "Stage: %i / %i", g_iPlayerPracLocationSnap[client][g_iLastSaveLocIdClient[client]], g_TotalStages);
}
else
{
Format(szStage, 64, "Stage: %i / %i", g_Stage[g_iClientInZone[client][2]][client], (g_mapZonesTypeCount[g_iClientInZone[client][2]][3] + 1));
Format(szStage, 64, "Stage: %i / %i", g_Stage[g_iClientInZone[client][2]][client], g_TotalStages);
}
}
else
{
Format(szStage, 64, "Stage: %i / %i", g_Stage[g_iClientInZone[client][2]][client], (g_mapZonesTypeCount[g_iClientInZone[client][2]][3] + 1));
Format(szStage, 64, "Stage: %i / %i", g_Stage[g_iClientInZone[client][2]][client], g_TotalStages);
}

char szWrcpTime[64];
Expand Down Expand Up @@ -3935,7 +3935,7 @@ public void Checkpoint(int client, int zone, int zonegroup, float time)
{
if (!IsValidClient(client) || g_bPositionRestored[client] || IsFakeClient(client) || zone >= CPLIMIT)
return;

g_iCPStartFrame_CurrentRun[0][zone][client] = g_iRecordedTicks[client];

float percent = -1.0;
Expand All @@ -3944,10 +3944,10 @@ public void Checkpoint(int client, int zone, int zonegroup, float time)
char szSpecMessage[512];

if (g_bhasStages) // If staged map
totalPoints = g_mapZonesTypeCount[zonegroup][3];
totalPoints = g_TotalStages;
else
if (g_mapZonesTypeCount[zonegroup][4] > 0) // If Linear Map and checkpoints
totalPoints = g_mapZonesTypeCount[zonegroup][4];
if (g_iTotalCheckpoints > 0) // If Linear Map and checkpoints
totalPoints = g_iTotalCheckpoints;

// Count percent of completion
percent = (float(zone + 1) / float(totalPoints + 1));
Expand Down
Loading