The LOLWUT 6 command: * * LOLWUT [columns] [rows] * * By default the command uses 80 columns, 40 squares per row * per column. */
| 167 | * per column. |
| 168 | */ |
| 169 | void lolwut6Command(client *c) { |
| 170 | long cols = 80; |
| 171 | long rows = 20; |
| 172 | |
| 173 | /* Parse the optional arguments if any. */ |
| 174 | if (c->argc > 1 && |
| 175 | getLongFromObjectOrReply(c,c->argv[1],&cols,NULL) != C_OK) |
| 176 | return; |
| 177 | |
| 178 | if (c->argc > 2 && |
| 179 | getLongFromObjectOrReply(c,c->argv[2],&rows,NULL) != C_OK) |
| 180 | return; |
| 181 | |
| 182 | /* Limits. We want LOLWUT to be always reasonably fast and cheap to execute |
| 183 | * so we have maximum number of columns, rows, and output resulution. */ |
| 184 | if (cols < 1) cols = 1; |
| 185 | if (cols > 1000) cols = 1000; |
| 186 | if (rows < 1) rows = 1; |
| 187 | if (rows > 1000) rows = 1000; |
| 188 | |
| 189 | /* Generate the city skyline and reply. */ |
| 190 | lwCanvas *canvas = lwCreateCanvas(cols,rows,3); |
| 191 | generateSkyline(canvas); |
| 192 | sds rendered = renderCanvas(canvas); |
| 193 | rendered = sdscat(rendered, |
| 194 | "\nDedicated to the 8 bit game developers of past and present.\n" |
| 195 | "Original 8 bit image from Plaguemon by hikikomori. Redis ver. "); |
| 196 | rendered = sdscat(rendered,REDIS_VERSION); |
| 197 | rendered = sdscatlen(rendered,"\n",1); |
| 198 | addReplyVerbatim(c,rendered,sdslen(rendered),"txt"); |
| 199 | sdsfree(rendered); |
| 200 | lwFreeCanvas(canvas); |
| 201 | } |
no test coverage detected