From b339f28f2f65c4ce447274211ccbe24e8e5101ac Mon Sep 17 00:00:00 2001 From: HF Date: Thu, 7 May 2020 09:20:00 +0200 Subject: [PATCH] Change mooncanvas size --- .gitignore | 3 + src/canvases.json | 4 +- utils/README.md | 3 + utils/change-canvasbackup/README.md | 2 + utils/change-canvasbackup/empty.png | Bin 0 -> 565 bytes utils/change-canvasbackup/emptybl.png | Bin 0 -> 567 bytes utils/change-canvasbackup/move.sh | 102 +++++++++++++++++++++++++ utils/change-canvasbackup/redisMove.js | 38 +++++++++ 8 files changed, 150 insertions(+), 2 deletions(-) create mode 100644 utils/change-canvasbackup/README.md create mode 100644 utils/change-canvasbackup/empty.png create mode 100644 utils/change-canvasbackup/emptybl.png create mode 100644 utils/change-canvasbackup/move.sh create mode 100644 utils/change-canvasbackup/redisMove.js diff --git a/.gitignore b/.gitignore index 21526b65..50a30b93 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,9 @@ players.json .digitalocean database.sqlite .ftpquota +lol.png +lol-cleaned.png +clean.png # Created by https://www.gitignore.io/api/node,webstorm diff --git a/src/canvases.json b/src/canvases.json index 82c97530..6373b684 100644 --- a/src/canvases.json +++ b/src/canvases.json @@ -83,7 +83,7 @@ [ 122, 148, 156 ], [ 174, 215, 185 ] ], - "size" : 1024, + "size" : 4096, "cli": 2, "bcd": 15000, "pcd": 15000, @@ -206,6 +206,6 @@ "ranked" : false, "req": 0, "sd": "2020-03-15", - "desc": "Special canvas to spread aweareness of coronavirus (doesn't count towards statistics)" + "desc": "Special canvas to spread awareness of SARS-CoV2 (doesn't count towards statistics)" } } diff --git a/utils/README.md b/utils/README.md index 59690202..55f5cd9c 100644 --- a/utils/README.md +++ b/utils/README.md @@ -57,3 +57,6 @@ Usage: `./liveLog.sh LOGFILE CANVASID STARTX_STARTY ENDX_ENDY` ## pp-center\*.png center logo of pixelplanet + +## change-canvasbackup +just a script that got run once to add the missing tiles in historical view when increasing the size of the moon canvas. diff --git a/utils/change-canvasbackup/README.md b/utils/change-canvasbackup/README.md new file mode 100644 index 00000000..1942b27a --- /dev/null +++ b/utils/change-canvasbackup/README.md @@ -0,0 +1,2 @@ +This script got used while increasing the size of the moon canvas. +It just adds additional empty tiles in the daily backup to pad the size in historical view, no big deal. diff --git a/utils/change-canvasbackup/empty.png b/utils/change-canvasbackup/empty.png new file mode 100644 index 0000000000000000000000000000000000000000..39c5bc6ba72b36a96f2949907a8b53ba57b208a2 GIT binary patch literal 565 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K58911L)MWvCLm=mmr;B4q#jUrO9eEiTIF1+` z*uO^jm^AMep=oO-i`1A3B`_E;NHFj)urV+ zItu)m{kWGcigS8Q$+hOy`&c9xco^6im>U=mFeES-Fi@LI8&i?pOEafKETMLQAUho# g^0Wwbh$S0%uShWU#rvgL022g*r>mdKI;Vst0F`@K0RR91 literal 0 HcmV?d00001 diff --git a/utils/change-canvasbackup/move.sh b/utils/change-canvasbackup/move.sh new file mode 100644 index 00000000..c4436ac4 --- /dev/null +++ b/utils/change-canvasbackup/move.sh @@ -0,0 +1,102 @@ +#!/bin/bash +# this script creates tiles in the backup folder for the moon canvas +# to be able to increase its size from 1024 to 4096 +# If it wouldn't be padded by those additional tiles, it would show loading tiles +# in historical view at the parts that exceed the previous size +# (which wouldn't be too bad tbh. but let be save and put those there) + +CANVAS=1 + +for DATEFOLDERS in `ls` +do + TILEFOLDER="${DATEFOLDERS}/${CANVAS}/tiles" + if [ -d "${TILEFOLDER}" ] + then + y=15 + while [ $y -ge 0 ] + do + TILEYDIR="${TILEFOLDER}/${y}" + if [ ! -d "${TILEYDIR}" ] + then + mkdir "${TILEYDIR}" + fi + + if [ $y -lt 4 ] + then + newy=$(( $y + 6 )) + NEWTILEYDIR="${TILEFOLDER}/${newy}" + echo "Move ${TILEYDIR} to ${NEWTILEYDIR}" + mv "${NEWTILEYDIR}" ./tmptiledir + mv "${TILEYDIR}" "${NEWTILEYDIR}" + mv ./tmptiledir "${TILEYDIR}" + + x=15 + while [ $x -ge 0 ] + do + TILE="${NEWTILEYDIR}/${x}.png" + if [ $x -lt 4 ] + then + newx=$(( $x + 6 )) + NEWTILE="${NEWTILEYDIR}/${newx}.png" + echo "Move ${TILE} to ${NEWTILE}" + mv "${NEWTILE}" ./tmptile.png + mv "${TILE}" "${NEWTILE}" + mv ./tmptile.png "${TILE}" + else + if [ ! -f "${TILE}" ] + then + cp ./empty.png "${TILE}" + echo "Create ${TILE}" + fi + fi + x=$(( $x - 1 )) + done + else + x=0 + while [ $x -lt 16 ] + do + TILE="${TILEYDIR}/${x}.png" + if [ ! -f "${TILE}" ] + then + cp ./empty.png "${TILE}" + echo "Create ${TILE}" + fi + x=$(( $x + 1 )) + done + fi + y=$(( $y - 1 )) + done + fi +done + +for DATEFOLDERS in `ls -d */` +do + CANVASFOLDER="${DATEFOLDERS}${CANVAS}" + if [ -d "${CANVASFOLDER}" ] + then + for TIMES in `ls ${CANVASFOLDER}` + do + if [ "${TIMES}" != "tiles" ] + then + TIMEFOLDER="${CANVASFOLDER}/${TIMES}" + for y in `ls -r "${TIMEFOLDER}"` + do + newy=$(( $y + 6 )) + TILEYDIR="${TIMEFOLDER}/${y}" + NEWTILEYDIR="${TIMEFOLDER}/${newy}" + echo "Move ${TILEYDIR} to ${NEWTILEYDIR}" + mv "${TILEYDIR}" "${NEWTILEYDIR}" + for XNAME in `ls -r ${NEWTILEYDIR}` + do + x=`echo ${XNAME} | sed 's/.png//'` + newx=$(( $x + 6 )) + TILE="${NEWTILEYDIR}/${x}.png" + NEWTILE="${NEWTILEYDIR}/${newx}.png" + echo "Move ${TILE} to ${NEWTILE} " + mv "${TILE}" "${NEWTILE}" + done + done + fi + done + fi +done diff --git a/utils/change-canvasbackup/redisMove.js b/utils/change-canvasbackup/redisMove.js new file mode 100644 index 00000000..a825e55b --- /dev/null +++ b/utils/change-canvasbackup/redisMove.js @@ -0,0 +1,38 @@ +/* @flow */ +// move chunks to the middle when changing size on moon canvas from 1024 to 4096 + +import redis from 'redis'; +import bluebird from 'bluebird'; +bluebird.promisifyAll(redis.RedisClient.prototype); +bluebird.promisifyAll(redis.Multi.prototype); + +//ATTENTION Make sure to set the rdis URLs right!!! +const oldurl = "redis://localhost:6380"; +const oldredis = redis.createClient(oldurl, { return_buffers: true }); +const newurl = "redis://localhost:6379"; +const newredis = redis.createClient(newurl, { return_buffers: true }); + +async function copyChunks() { + for (let x = 0; x < 5; x++) { + for (let y = 0; y < 5; y++) { + const oldkey = `ch:1:${x}:${y}`; + const newkey = `ch:1:${x + 6}:${y + 6}`; + const chunk = await oldredis.getAsync(oldkey); + if (chunk) { + const setNXArgs = [newkey, chunk]; + await oldredis.sendCommandAsync('SET', setNXArgs); + await oldredis.delAsync(oldkey); + console.log("Created Chunk ", newkey); + } + const chunkl = await newredis.getAsync(oldkey); + if (chunkl) { + const setNXArgs = [newkey, chunkl]; + await newredis.sendCommandAsync('SET', setNXArgs); + await newredis.delAsync(oldkey); + console.log("Created Chunk ", newkey); + } + } + } +} + +copyChunks();