vodur:luaafile
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| vodur:luaafile [2015/11/01 07:27] – vodur | vodur:luaafile [2015/11/11 04:40] (current) – vodur | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ===== Pros/Cons for new method: ===== | ||
| + | |||
| + | Pros:\\ | ||
| + | Less messy/ | ||
| + | Can easily parse area files with outside scripts for analysis. | ||
| + | |||
| + | Cons:\\ | ||
| + | Less performant (bigger filesize, slower save/ | ||
| + | Confusing to use new save/load code? | ||
| + | |||
| + | ===== Example old saving code: ===== | ||
| + | |||
| + | <code C> | ||
| + | fprintf( fp, "#VER %d\n", CURR_AREA_VERSION ); | ||
| + | |||
| + | for ( i = 0; i < | ||
| + | if ( pArea-> | ||
| + | fprintf( fp, "# | ||
| + | |||
| + | fprintf( fp, " | ||
| + | rfprintf( fp, "Name %s~\n", | ||
| + | rfprintf( fp, " | ||
| + | rfprintf( fp, " | ||
| + | fprintf( fp, "VNUMs %d %d\n", | ||
| + | rfprintf( fp, " | ||
| + | /* Added minlevel, maxlevel, and miniquests for new areas command | ||
| + | | ||
| + | fprintf( fp, " | ||
| + | fprintf( fp, " | ||
| + | fprintf( fp, " | ||
| + | fprintf( fp, " | ||
| + | fprintf( fp, "Time %d\n", | ||
| + | if (IS_SET(pArea-> | ||
| + | fprintf( fp, " | ||
| + | if (IS_SET(pArea-> | ||
| + | fprintf( fp, " | ||
| + | if (IS_SET(pArea-> | ||
| + | fprintf( fp, " | ||
| + | if ( IS_SET(pArea-> | ||
| + | fprintf(fp, " | ||
| + | |||
| + | /* save aprogs if any */ | ||
| + | if (pArea-> | ||
| + | { | ||
| + | PROG_LIST *pAprog; | ||
| + | reverse_aprog_order(pArea); | ||
| + | for (pAprog = pArea-> | ||
| + | { | ||
| + | rfprintf(fp, | ||
| + | } | ||
| + | reverse_aprog_order(pArea); | ||
| + | } | ||
| + | </ | ||
| + | |||
| ===== Example new saving code: ===== | ===== Example new saving code: ===== | ||
| Line 70: | Line 124: | ||
| LStbl_release( LS, &area ); | LStbl_release( LS, &area ); | ||
| </ | </ | ||
| + | |||
| ===== Example old format (Bastion) ===== | ===== Example old format (Bastion) ===== | ||
| Line 89: | Line 144: | ||
| End | End | ||
| </ | </ | ||
| + | |||
| ===== Example new format (Bastion) ===== | ===== Example new format (Bastion) ===== | ||
| Line 123: | Line 179: | ||
| } | } | ||
| </ | </ | ||
| + | |||
| ===== Example old format (Remort 6) ===== | ===== Example old format (Remort 6) ===== | ||
| Line 144: | Line 201: | ||
| End | End | ||
| </ | </ | ||
| + | |||
| ===== Example new format (Remort 6) ===== | ===== Example new format (Remort 6) ===== | ||
| Line 175: | Line 233: | ||
| } | } | ||
| </ | </ | ||
| + | |||
| + | ===== Example old loading code: ===== | ||
| + | |||
| + | <code C> | ||
| + | for ( ; ; ) | ||
| + | { | ||
| + | word = feof( fp ) ? " | ||
| + | fMatch = FALSE; | ||
| + | |||
| + | switch ( UPPER(word[0]) ) | ||
| + | { | ||
| + | /* Added for the new areas command - Astark Dec 2012 */ | ||
| + | case ' | ||
| + | if (!str_cmp(word, | ||
| + | { | ||
| + | PROG_LIST *pAprog; | ||
| + | const char *word; | ||
| + | int trigger = 0; | ||
| + | |||
| + | pAprog | ||
| + | word = fread_word( fp ); | ||
| + | if ( (trigger = flag_lookup( word, aprog_flags )) == NO_FLAG ) | ||
| + | { | ||
| + | bugf(" | ||
| + | exit(1); | ||
| + | } | ||
| + | SET_BIT(pArea-> | ||
| + | pAprog-> | ||
| + | pAprog-> | ||
| + | pAprog-> | ||
| + | pAprog-> | ||
| + | pArea-> | ||
| + | } | ||
| + | break; | ||
| + | case ' | ||
| + | KEY(" | ||
| + | KEY(" | ||
| + | KEY(" | ||
| + | case ' | ||
| + | SKEY( " | ||
| + | if ( !str_cmp(word, | ||
| + | { | ||
| + | SET_BIT(pArea-> | ||
| + | break; | ||
| + | } | ||
| + | if ( !str_cmp(word, | ||
| + | { | ||
| + | SET_BIT(pArea-> | ||
| + | break; | ||
| + | } | ||
| + | SKEY( " | ||
| + | break; | ||
| + | case ' | ||
| + | if ( !str_cmp(word, | ||
| + | SET_BIT(pArea-> | ||
| + | break; | ||
| + | case ' | ||
| + | KEY( " | ||
| + | if ( !str_cmp(word, | ||
| + | { | ||
| + | SET_BIT(pArea-> | ||
| + | break; | ||
| + | } | ||
| + | break; | ||
| + | case ' | ||
| + | KEY(" | ||
| + | case ' | ||
| + | if ( !str_cmp( word, " | ||
| + | { | ||
| + | pArea-> | ||
| + | pArea-> | ||
| + | } | ||
| + | break; | ||
| + | case ' | ||
| + | if ( !str_cmp( word, " | ||
| + | { | ||
| + | fMatch = TRUE; | ||
| + | if ( area_first == NULL ) | ||
| + | area_first = pArea; | ||
| + | if ( area_last | ||
| + | area_last-> | ||
| + | |||
| + | area_last | ||
| + | pArea-> | ||
| + | current_area = pArea; | ||
| + | top_area++; | ||
| + | |||
| + | return; | ||
| + | } | ||
| + | break; | ||
| + | case ' | ||
| + | SKEY( " | ||
| + | break; | ||
| + | case ' | ||
| + | SKEY( " | ||
| + | break; | ||
| + | } | ||
| + | |||
| + | if ( !fMatch ) | ||
| + | { | ||
| + | // no nothing but avoid warning | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| ===== Example new loading code: ===== | ===== Example new loading code: ===== | ||
vodur/luaafile.1446362868.txt.gz · Last modified: 2015/11/01 07:27 by vodur