A Deno-powered backend service for Plants vs. Zombies: MODDED. [Read-only GitHub mirror] docs.pvzm.net
express typescript expressjs plant deno jspvz pvzm game online backend plants-vs-zombies zombie javascript plants modded vs plantsvszombies openapi pvz noads
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ClaytonTDM - fix decoder Original commit: https://github.com/ROBlNET13/pvzm-backend/commit/5a1cf4c3a19d202b97ea5d4ae464a4358da34979

+24 -7
+22 -6
modules/decode.ts
··· 174 174 ): string { 175 175 const inputData = Array.isArray(compressed) 176 176 ? new Uint8Array(compressed) 177 - : (compressed instanceof ArrayBuffer ? new Uint8Array(compressed) : compressed); 177 + : (compressed instanceof ArrayBuffer 178 + ? new Uint8Array(compressed) 179 + : compressed); 178 180 179 181 const decompressed = pako.inflate(inputData); 180 182 return new TextDecoder().decode(decompressed); ··· 235 237 const obj = msgpackDecode(msgpackBytes); 236 238 const reversed = reverseKeys(obj); 237 239 238 - if (reversed.lfValue !== undefined && typeof reversed.lfValue === "number") { 240 + if ( 241 + reversed.lfValue !== undefined && typeof reversed.lfValue === "number" 242 + ) { 239 243 reversed.lfValue = unpackToArray(reversed.lfValue); 240 244 } 241 245 return reversed; ··· 261 265 const plantData = plantString.slice(1, -1).split("\uE002"); 262 266 263 267 for (const plantPair of plantData) { 264 - const [plantTinyKey, plantValueStr] = plantPair.split("\uE004"); 268 + const [plantTinyKey, plantValueStr] = plantPair.split( 269 + "\uE004", 270 + ); 265 271 const plantOriginalKey = REVERSE_TINYIFIER_MAP[ 266 272 parseInt(plantTinyKey, 10) 267 273 ] as keyof Plant; ··· 269 275 if (!plantOriginalKey) continue; 270 276 271 277 // match frontend OLD behavior: only these are forced numeric 272 - if (["zIndex", "plantRow", "plantCol"].includes(plantOriginalKey)) { 273 - plantObj[plantOriginalKey] = parseInt(plantValueStr, 10); 278 + if ( 279 + ["zIndex", "plantRow", "plantCol"].includes( 280 + plantOriginalKey, 281 + ) 282 + ) { 283 + plantObj[plantOriginalKey] = parseInt( 284 + plantValueStr, 285 + 10, 286 + ); 274 287 } else { 275 288 plantObj[plantOriginalKey] = plantValueStr; 276 289 } ··· 282 295 } else if (originalKey === "lfValue") { 283 296 originalClone[originalKey] = tinyValue.split("\uE000").map(Number); 284 297 } else if (["sun", "stripeCol"].includes(originalKey)) { 285 - originalClone[originalKey as "sun" | "stripeCol"] = parseInt(tinyValue, 10); 298 + originalClone[originalKey as "sun" | "stripeCol"] = parseInt( 299 + tinyValue, 300 + 10, 301 + ); 286 302 } else { 287 303 originalClone[originalKey as keyof Clone] = tinyValue as any; 288 304 }
+2 -1
modules/validate.ts
··· 229 229 } 230 230 231 231 export function validateClone(clone: Clone): boolean { 232 - let [doesCloneHaveAllRequiredFields, missingFields] = cloneHasAllRequiredFields(clone); 232 + let [doesCloneHaveAllRequiredFields, missingFields] = 233 + cloneHasAllRequiredFields(clone); 233 234 if (!doesCloneHaveAllRequiredFields) { 234 235 console.error("Clone is missing required fields:", missingFields); 235 236 return false;