Skip to content

Commit 6524daa

Browse files
committed
Backwards compatibility fixes
1 parent 59e58d0 commit 6524daa

3 files changed

Lines changed: 24 additions & 20 deletions

File tree

cloudbox.go

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,36 +67,38 @@ func main() {
6767
http.HandleFunc("GET /content/fastdl", content.FastDL)
6868

6969
// stats.garrysmod.com
70-
http.HandleFunc("GET stats.garrysmod.com/API/mapload_001/", stats.MapLoad)
70+
http.HandleFunc("GET stats.garrysmod.com/API/mapload_001/", stats.MapLoad) // v102 - v142
7171

7272
// toyboxapi.garrysmod.com
7373
// auth
74-
http.HandleFunc("GET toyboxapi.garrysmod.com/auth_001/", toyboxapi.Auth)
75-
http.HandleFunc("POST toyboxapi.garrysmod.com/auth_002/", toyboxapi.Auth)
76-
http.HandleFunc("POST toyboxapi.garrysmod.com/auth_003/", toyboxapi.Auth)
74+
http.HandleFunc("GET toyboxapi.garrysmod.com/auth_001/", toyboxapi.Auth) // v104 - v106
75+
http.HandleFunc("POST toyboxapi.garrysmod.com/auth_002/", toyboxapi.Auth) // v107 - v133
76+
http.HandleFunc("POST toyboxapi.garrysmod.com/auth_003/", toyboxapi.Auth) // v134 - v142
7777

7878
// getinstall
79-
http.HandleFunc("GET toyboxapi.garrysmod.com/getinstall_001/", toyboxapi.GetPackage)
80-
http.HandleFunc("GET toyboxapi.garrysmod.com/getinstall_003/", toyboxapi.GetPackage)
79+
http.HandleFunc("GET toyboxapi.garrysmod.com/getinstall_003/", toyboxapi.GetPackage) // v134 - v142
8180

8281
// getscript
83-
http.HandleFunc("GET toyboxapi.garrysmod.com/getscript_001/", toyboxapi.GetPackage)
84-
http.HandleFunc("GET toyboxapi.garrysmod.com/getscript_003/", toyboxapi.GetPackage)
82+
http.HandleFunc("GET toyboxapi.garrysmod.com/getscript_001/", toyboxapi.GetPackage) // v100 - v133
83+
http.HandleFunc("GET toyboxapi.garrysmod.com/getscript_003/", toyboxapi.GetPackage) // v134 - v142
8584

8685
// upload
87-
http.HandleFunc("POST toyboxapi.garrysmod.com/upload_001/", toyboxapi.Upload)
88-
http.HandleFunc("POST toyboxapi.garrysmod.com/upload_003/", toyboxapi.Upload)
86+
http.HandleFunc("POST toyboxapi.garrysmod.com/upload_001/", toyboxapi.Upload) // v109 - v133
87+
http.HandleFunc("POST toyboxapi.garrysmod.com/upload_003/", toyboxapi.Upload) // v134 - v142
8988

9089
// error
91-
http.HandleFunc("GET toyboxapi.garrysmod.com/error_001/", toyboxapi.Error)
92-
http.HandleFunc("GET toyboxapi.garrysmod.com/error_003/", toyboxapi.Error)
90+
http.HandleFunc("GET toyboxapi.garrysmod.com/error_001/", toyboxapi.Error) // v98 - v133
91+
http.HandleFunc("GET toyboxapi.garrysmod.com/error_003/", toyboxapi.Error) // v134 - v142
9392

9493
// publishsave
95-
http.HandleFunc("GET toyboxapi.garrysmod.com/publishsave_002/", publishsave.Save)
96-
http.HandleFunc("POST toyboxapi.garrysmod.com/publishsave_002/", publishsave.Publish)
94+
http.HandleFunc("GET toyboxapi.garrysmod.com/publishsave_001/", publishsave.Save) // v106 - v108
95+
http.HandleFunc("GET toyboxapi.garrysmod.com/publishsave_002/", publishsave.Save) // v109 - v142
96+
97+
http.HandleFunc("POST toyboxapi.garrysmod.com/publishsave_001/", publishsave.Publish) // v106 - v108
98+
http.HandleFunc("POST toyboxapi.garrysmod.com/publishsave_002/", publishsave.Publish) // v109 - v142
9799

98100
// mapload (legacy)
99-
http.HandleFunc("GET toyboxapi.garrysmod.com/mapload_001/", stats.MapLoad)
101+
http.HandleFunc("GET toyboxapi.garrysmod.com/mapload_001/", stats.MapLoad) // v98 - v101
100102

101103
err = http.ListenAndServe(fmt.Sprintf(":%d", *port), nil)
102104
if err != nil {

data/templates/publishsave/save.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<body>
66
<div id="container">
77
<h2>Publish Saved Game</h2>
8-
<form action="/API/publishsave_002/?id={{.ID}}&sid={{.SID}}" method="post">
8+
<form action="?id={{.ID}}{{if ne .SID 0}}&sid={{.SID}}{{end}}" method="post">
99
<div class="row">
1010
<label for="name">Name:</label>
1111
<input type="text" name="name" id="name" required>

ingame/publishsave/save.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@ func Save(w http.ResponseWriter, r *http.Request) {
4848
return
4949
}
5050

51-
sd.SID, err = strconv.Atoi(r.URL.Query().Get("sid"))
52-
if err != nil {
53-
utils.WriteError(w, r, fmt.Sprintf("failed to parse sid value: %s", err))
54-
return
51+
if r.URL.Path == "/publishsave_002/" {
52+
sd.SID, err = strconv.Atoi(r.URL.Query().Get("sid"))
53+
if err != nil {
54+
utils.WriteError(w, r, fmt.Sprintf("failed to parse sid value: %s", err))
55+
return
56+
}
5557
}
5658

5759
err = ts.Execute(w, sd)

0 commit comments

Comments
 (0)