Overview
Comment: | Some more changes in game.c and in documentation, to work with the new move list encoding/decoding functions. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
c295ff21b6157bfc9e33807367f160dd |
User & Date: | user on 2022-06-28 03:57:49 |
Other Links: | manifest | tags |
Context
2022-06-28
| ||
04:45 | Use the move encoding functions in the level import function. check-in: 5463756bc9 user: user tags: trunk | |
03:57 | Some more changes in game.c and in documentation, to work with the new move list encoding/decoding functions. check-in: c295ff21b6 user: user tags: trunk | |
2022-06-26
| ||
04:05 | Use the new move list functions in move list import/export functions, and change the type of replay_size from Uint16 to size_t. check-in: cafa4fd29b user: user tags: trunk | |
Changes
Modified fileformat.doc from [490957ffa7] to [723b223c5e].
︙ | |||
133 134 135 136 137 138 139 140 141 142 143 144 145 146 | 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | + + + | of this lump has the following format: * Level version number (16-bits small-endian): If this does not match the level version number in the .LVL lump, then the solution is considered to be invalid. * Flags (8-bits): Specifies which other fields are present. * Score (signed 32-bits small-endian; only present if flag bit7 is set): The score of this level. Lower numbers are better. * Comment (null-terminated; only present if flag bit0 set): Normally contains a user name, but may be any arbitrary text. * Timestamp (64-bits small-endian; only present if flag bit1 set): The UNIX timestamp when the solution was recorded. |
︙ |
Modified game.c from [dd24aafcf7] to [e7202bf383].
1 | 1 2 3 4 5 6 7 8 9 | - + | #if 0 |
︙ | |||
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | + + - + - + | // Returns the number of bytes of the encoded move. fputc(v,fp); return 1; } int encode_move_list(FILE*fp) { // Encodes the current replay list into the file; returns the number of bytes. // Does not write a null terminator. fwrite(replay_list,1,replay_count,fp); return replay_count; } MoveItem decode_move(FILE*fp) { // Decodes a single move from the file, and returns the move. // Returns zero if there is no more moves. int v=fgetc(fp); return (v==EOF?0:v); } int decode_move_list(FILE*fp) { // Decodes a move list from the file, and stores it in replay_list and replay_count. // Returns the number of moves (replay_count). MoveItem v; FILE*o; free(replay_list); replay_list=0; replay_size=0; replay_count=0; |
︙ | |||
287 288 289 290 291 292 293 | 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 | + - - - + + + + - - - + + + + + + + + + + - - - - + + + + - - - - - + + + + + + + - + + + + - - - + + + + + - - - - - - - + + + + + + + + + + + + + - - - - - - - - + - - - + + + + + - - - + + + - + + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | SDL_LockSurface(screen); draw_text(0,40,buf,0xF0,0xF1); SDL_UnlockSurface(screen); SDL_Flip(screen); } static void save_replay(void) { unsigned char*buf=0; |
︙ | |||
1326 1327 1328 1329 1330 1331 1332 | 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 | - + - + - + - - - - + + + + + - - - - - - - + + + + + + + + + + + + - + + + + - - - - + + + + + + - - - - + + + - + + + - + - - - - + - - - - + + + + + + + | } timerflag=1; return n; } static inline void input_move(Uint8 k) { const char*t=execute_turn(k); |
︙ |
Modified internals.doc from [a0bdf57f86] to [72305d8afa].
︙ | |||
117 118 119 120 121 122 123 | 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | 16 (\q) = Quiz button 30 (\d) = Data 31 (\x) = Next byte is a character to display as graphic Codes 32-255 are displayed as is, but characters 1-31 cannot be displayed as a graphic unless a \x escape is present. === User state data === The user state data for levels in the user cache database can be in the old format or the new format. The old format is: * The move list. Only single-byte moves are valid. * The replay mark position (a big-endian 16-bit number). * The level version number (a big-endian 16-bit number); this will match the actual level version number if the player has solved this level, or otherwise will not match. * The number of moves in the move list. The new format starts with a null byte, and then is followed by any number of records. The first byte of a record determines its format: * 0x01 to 0x3F = Null-terminated * 0x41 to 0x7F = Two more bytes * 0x81 to 0xBF = Four more bytes * 0xC1 to 0xFF = Eight more bytes The new format is always small-endian. Record types: * 0x01 = Replay list * 0x41 = Level version, if solved (omitted otherwise) * 0x42 = Mark position |