int main() { int i; int b = 99; int c = 999; //printf("%d\n",copyval(b)); //printf("%d\n",modval(&c)); for(i=1;i<=2 ; i++){ copyval(b); modval(&c); printf("%d\n",b); printf("%d\n",c); } return 0; }
void dnTakeSnapshot( snapshot_t *snapshot ) { copyval( numwalls ); copyarr( wall ); copyval( numsectors ); copyarr( sector ); copyarr( sprite ); copyarr( spriteext ); copyarr( headspritesect ); copyarr( prevspritesect ); copyarr( nextspritesect ); copyarr( headspritestat ); copyarr( prevspritestat ); copyarr( nextspritestat ); copyval( numcyclers ); copyarr( cyclers ); copyarr( ps ); copyarr( po ); copyval( numanimwalls ); copyarr( animwall ); copyarr( msx ); copyarr( msy ); copyval( spriteqloc ); copyval( spriteqamount ); copyarr( spriteq ); copyval( mirrorcnt ); copyarr( mirrorwall ); copyarr( mirrorsector ); /* char show2dsector[(MAXSECTORS+7)>>3]; */ copyarr( actortype ); copyval( numclouds ); copyarr( clouds ); copyarr( cloudx ); copyarr( cloudy ); #if WITH_SCRIPTS for (int i = 0; i < MAXSCRIPTSIZE; i++ ) { if ( (long)script[i] >= (long)(&script[0]) && (long)script[i] < (long)(&script[MAXSCRIPTSIZE]) ) { snapshot->scriptptrs[i] = 1; snapshot->script[i] = (long)script[i] - (long)&script[0]; } else { snapshot->scriptptrs[i] = 0; snapshot->script[i] = 0xFFFFFFFF; } } for( int i = 0; i < MAXTILES-VIRTUALTILES; i++ ) { if ( actorscrptr[i] ) { snapshot->actorscrptr[i] = (long)actorscrptr[i]-(long)&script[0]; } else { snapshot->actorscrptr[i] = 0; } } #endif #if WITH_HITTYPE for( int i = 0; i < MAXSPRITES; i++ ) { weaponhit wh = { 0 }; snapshot->hittypeflags[i] = 0; memcpy( &wh, &hittype[i], sizeof( weaponhit ) ); if ( actorscrptr[ sprite[i].picnum ] != 0 ) { unsigned int begin = (unsigned int)&script[0]; unsigned int end = (unsigned int)&script[MAXSCRIPTSIZE]; if ( hittype[i].temp_data[1] >= begin && hittype[i].temp_data[1] < end ) { snapshot->hittypeflags[i] |= 1; wh.temp_data[1] = hittype[i].temp_data[1] - begin; } if ( hittype[i].temp_data[4] >= begin && hittype[i].temp_data[4] < end ) { snapshot->hittypeflags[i] |= 2; wh.temp_data[4] = hittype[i].temp_data[4] - begin; } if ( hittype[i].temp_data[5] >= begin && hittype[i].temp_data[5] < end ) { snapshot->hittypeflags[i] |= 4; wh.temp_data[5] = hittype[i].temp_data[5] - begin; } } memcpy( &snapshot->hittype[i], &wh, sizeof( weaponhit ) ); } #endif copyval( lockclock ); copyval( pskybits ); copyarr( pskyoff ); copyval( animatecnt ); copyarr( animatesect ); copyoffs( animateptr, §or[0] ); copyarr( animategoal ); copyarr( animatevel ); copyval( earthquaketime ); copyudval( from_bonus ); copyudval( secretlevel ); copyudval_m( respawn_monsters ); copyudval_m( respawn_items ); copyudval_m( respawn_inventory ); copyudval_m( monsters_off ); copyudval_m( coop ); copyudval_m( marker ); copyudval_m( ffire ); copyval( numplayersprites ); copyarr( frags ); copyval( randomseed ); copyval( global_random ); copyval( parallaxyscale ); memset( &snapshot->padding[0], 0, sizeof( snapshot->padding ) ); }
void dnRestoreSnapshot( const snapshot_t *snapshot ) { copyval( numwalls ); copyarr( wall ); copyval( numsectors ); copyarr( sector ); copyarr( sprite ); copyarr( spriteext ); copyarr( headspritesect ); copyarr( prevspritesect ); copyarr( nextspritesect ); copyarr( headspritestat ); copyarr( prevspritestat ); copyarr( nextspritestat ); copyval( numcyclers ); copyarr( cyclers ); char *palette[MAXPLAYERS]; char gm[MAXPLAYERS]; for ( int i = 0; i < MAXPLAYERS; i++ ) { palette[i] = ps[i].palette; gm[i] = ps[i].gm; } copyarr( ps ); for ( int i = 0; i < MAXPLAYERS; i++ ) { ps[i].palette = palette[i]; ps[i].gm = gm[i]; } copyarr( po ); copyval( numanimwalls ); copyarr( animwall ); copyarr( msx ); copyarr( msy ); copyval( spriteqloc ); copyval( spriteqamount ); copyarr( spriteq ); copyval( mirrorcnt ); /* char show2dsector[(MAXSECTORS+7)>>3]; */ copyarr( mirrorwall ); copyarr( mirrorsector ); copyarr( actortype ); copyval( numclouds ); copyarr( clouds ); copyarr( cloudx ); copyarr( cloudy ); #if WITH_SCRIPTS for ( int i = 0; i < MAXSCRIPTSIZE; i++ ) { if ( snapshot->scriptptrs[i] ) { script[i] = (long)&script[0] + snapshot->script[i]; } } for( int i = 0; i < MAXTILES-VIRTUALTILES; i++ ) { if ( snapshot->actorscrptr[i] ) { actorscrptr[i] = (long*)( (long)(&script[0]) + snapshot->actorscrptr[i] ); } else { actorscrptr[i] = 0; } } #endif #if WITH_HITTYPE copyarr( hittype ); for ( int i = 0; i < MAXSPRITES; i++ ) { unsigned char flags = snapshot->hittypeflags[i]; long j = (long)&script[0]; if ( flags & 1 ) { T2 += j; } if ( flags & 2 ) { T5 += j; } if ( flags & 4 ) { T6 += j; } } #endif copyval( lockclock ); copyval( pskybits ); copyarr( pskyoff ); copyval( animatecnt ); copyarr( animatesect ); copyoffs( animateptr, §or[0] ); /* !!! */ copyarr( animategoal ); copyarr( animatevel ); copyval( earthquaketime ); copyudval( from_bonus ); copyudval( secretlevel ); copyudval_m( respawn_monsters ); copyudval_m( respawn_items ); copyudval_m( respawn_inventory ); copyudval_m( monsters_off ); copyudval_m( coop ); copyudval_m( marker ); copyudval_m( ffire ); copyval( numplayersprites ); copyarr( frags ); copyval( randomseed ); copyval( global_random ); copyval( parallaxyscale ); }