void LoadPackArray(ResFile ff1,word* dest,int size) { word szs; word defv; RBlockRead(ff1,&szs,2); RBlockRead(ff1,&defv,2); for(int i=0; i<size; i++)dest[i]=defv; word ofst=0; word vall; for(i=0; i<szs; i++) { RBlockRead(ff1,&ofst,2); RBlockRead(ff1,&vall,2); dest[ofst]=vall; }; };
void InitExplosions(){ for(int i=0;i<MaxExpl;i++)GAnm[i]=new AnmObject; for(i=0;i<257;i++){ TSin[i]=short(256*sin(2*3.1415927*i/256)); TCos[i]=short(256*cos(2*3.1415927*i/256)); TAtg[i]=short(128*atan2(i,256)/3.1415927); }; memset(&EUsage,0,MaxExpl); LastReq=0; nEused=0; ResFile rf=RReset("random.lst"); RBlockRead(rf,randoma,16384); RClose(rf); // for(i=0;i<8192;i++){ // randoma[i]=rand(); // }; rpos=0; //ResFile rf=RRewrite("random.lst"); //RBlockWrite(rf,randoma,16384); //RClose(rf); };
void ProcessFog(){ byte z=0;//byte(rando()&1); __asm{ mov ecx,msx inc ecx lab1: mov ax,[fmap+ecx*2] mov [fmap+512+ecx*2],ax; mov ax,[fmap+256*255*2+ecx*2] mov [fmap+256*254*2+ecx*2],ax loop lab1 mov ecx,msy mov ebx,offset fmap+512 lab2: mov ax,[ebx] mov [ebx+2],ax mov ax,[ebx+510] mov [ebx+508],ax add ebx,512 loop lab2 cmp z,0 jne Process1 //Process0 mov bl,byte ptr msx mov bh,byte ptr msy mov ecx,offset fmap add ecx,514 lab3: mov dx,[ecx-512] add dx,[ecx+512] add dx,[ecx-2] add dx,[ecx+2] mov ax,dx //shr dx,8 //sub ax,dx shr ax,2 //cmp ax,MaxShad //ja iii or ax,63 sub ax,63 iii: mov [ecx],ax add ecx,2 dec bl jnz lab3 add ecx,512 sub ecx,msx sub ecx,msx mov bl,byte ptr msx dec bh jnz lab3 jmp ProcessFinished Process1: xor ebx,ebx mov bl,byte ptr msx mov bh,byte ptr msy mov ecx,offset fmap add ecx,ebx add ecx,ebx //add ecx,514 lab4: mov dx,[ecx-512] add dx,[ecx+512] add dx,[ecx-2] add dx,[ecx+2] mov ax,dx //shr dx,8 //sub ax,dx shr ax,2 //cmp ax,MaxShad //ja ioo or ax,63 sub ax,63 ioo: mov [ecx],ax sub ecx,2 dec bl jnz lab4 sub ecx,512 add ecx,msx add ecx,msx mov bl,byte ptr msx dec bh jnz lab3 ProcessFinished: }; }; void LoadFog(){ ResFile fx=RReset("darkb.grd");//004g.grd"); RBlockRead(fx,&fog[1024],8192); memcpy(&fog[0],&fog[1024],256); memcpy(&fog[256],&fog[1024],256); memcpy(&fog[512],&fog[1024],256); memcpy(&fog[512+256],&fog[1024],256); RClose(fx); //fx=RReset("003xw.grd"); fx=RReset("darkw.grd");//003cm.grd"); RBlockRead(fx,&wfog,8192); RClose(fx); fx=RReset("003xr.grd"); RBlockRead(fx,&yfog,8192); RClose(fx); fx=RReset("003xr1.grd"); RBlockRead(fx,&rfog,8192); RClose(fx); fx=RReset("darkfog.grd"); RBlockRead(fx,&darkfog,40960); RClose(fx); };
void LoadObjects(ResFile ff1) { //sigature checking int i; RBlockRead(ff1,&i,4); LOADMES(ff1); if(i!=0x494A424F)LOutErr("SAVE file is corrupted. Игры не будет.");//'OBJI' int NObjects=0; RBlockRead(ff1,&NObjects,4); RBlockRead(ff1,&MAXOBJECT,4); //Information for every object for(int tt=0; tt<NObjects; tt++) { word Indx; LOADMES(ff1); RBlockRead(ff1,&Indx,2); Group[Indx]=OBJECTS+Indx;//assign pointer OneObject* OB=Group[Indx]; OB->Index=Indx; //init path information OB->PathX=NULL; OB->PathY=NULL; OB->NIPoints=0; OB->CurIPoint=0; OB->CPdestX=0; OB->CPdestY=0; //Loading header information RBlockRead(ff1,&OB->NIndex,int(&OB->Media)-int(&OB->NIndex)+1); //Default object settings int x=OB->x; int y=OB->y; //1.Nation reference OB->Nat=&NATIONS[OB->NNUM]; Nation* NT=OB->Nat; //2.General object reference OB->Ref.General=NT->Mon[OB->NIndex]; GeneralObject* GO=OB->Ref.General; int ca; RBlockRead(ff1,&ca,4); OB->CurAnm=(Octant*)(int(NT->Animations)+ca); //3.Inside objects if(OB->Transport)OB->Inside=new word[6]; RBlockRead(ff1,&OB->NInside,2); if(OB->NInside)RBlockRead(ff1,OB->Inside,OB->NInside<<1); OB->TimeInside=NULL; //4. Other default information OB->Wars=NULL;//No Legion information OB->InLineCom=NULL; OB->LineOffset=0; //5.Animation registers memset(&(OB->ARegs),0,sizeof OB->ARegs); //6.Weapon assignment OB->Weap=GO->Weap; //7.Land/Water/Air information OB->LoadAnimation(0,0,0); Cell8x8* CELL=&TCInf[OB->NNUM][y>>2][x>>2]; CELL->UnitsAmount[GO->Kind]++; if(GO->OnWater) { if(!OB->Sdoxlo) { Mops[y][x]=Indx; WLock[y][x]=true; }; //WMap[y][x]=1; } else if(GO->OnAir) { RBlockRead(ff1,&OB->RealX,int(&OB->RealDir)-int(&OB->RealX)+1); OB->LoadAnimation(0,0,0);//stand=motion animation OB->LoadAnimation(1,2,0);//attack OB->LoadAnimation(2,3,0);//death if(!OB->Sdoxlo)FlyMops[y][x]=OB->Index; int cx=(OB->RealX-256)>>11; int cy=(OB->RealY-256)>>11; FlyCell* FC=&FlyMap[cy][cx]; for(int k=0; FC->FlyList[k]!=0xFFFF; k++); FC->NFly++; FC->FlyList[k]=OB->Index; } else { if(GO->cpbBuilding) {
void LOADMES(ResFile ff1) { char zzz[16]; RBlockRead(ff1,zzz,16); };
bool LoadNations(ResFile ff1) { int tt; RBlockRead(ff1,&tt,4); if(tt!=0x4954414E) { //'NATI'0x LOutErr("Save file is corrupted.Я не доктор по save- файлам."); return false; }; LOADMES(ff1); byte nn; RBlockRead(ff1,&nn,1); for(tt=0; tt<8; tt++) { LOADMES(ff1); char stri[16]; Nation* NT=&NATIONS[tt]; RBlockRead(ff1,stri,16); byte ms; byte ni; RBlockRead(ff1,&ms,1); RBlockRead(ff1,&ni,1); LoadNation(stri,ms,ni); CITY[ni].CreateCity(20,20,ni); LOADMES(ff1); RBlockRead(ff1,&NT->NMon,4); //Informtion about monsters(GeneralObject) for(int i=0; i<NT->NMon; i++) { GeneralObject* GO=NT->Mon[i]; Visuals* VS=(Visuals*)GO; LOADMES(ff1); RBlockRead(ff1,&nn,1); GO->NoSearchVictim=false; GO->NoAnswer=false; GO->NeedNoHelp=false; GO->Enabled=false; if(nn&1)GO->NoSearchVictim=true; if(nn&2)GO->NoAnswer=true; if(nn&4)GO->NeedNoHelp=true; if(nn&8)GO->Enabled=true; RBlockRead(ff1,&VS->info.Basic.MaxShield,2); RBlockRead(ff1,&VS->info.Basic.MinDamage,2); RBlockRead(ff1,&VS->info.Basic.MaxDamage,2); RBlockRead(ff1,&VS->info.Basic.MaxLife,2); RBlockRead(ff1,&VS->info.Basic.AttackRange,2); }; //Information about city LOADMES(ff1); City* CT=NT->CITY; RBlockRead(ff1,&CT->InX,34); RBlockRead(ff1,&nn,1); CT->PresentProject=false; CT->IntellectEnabled=false; if(nn&1)CT->PresentProject=true; if(nn&2)CT->IntellectEnabled=true; if(CT->IntellectEnabled) { //Load AI properties if intellect is enabled //1.Information about crowds(10+1 --defence) for(i=0; i<11; i++) { Crowd* CR=&CT->CROWDS[i]; RBlockRead(ff1,&CR->Amount,2); RBlockRead(ff1,&CR->NI,1); RBlockRead(ff1,&CR->MLSize,2); CR->MemList=new word[CR->MLSize]; RBlockRead(ff1,CR->MemList,CR->MLSize<<1); RBlockRead(ff1,&CR->LastDx,23*4); RBlockRead(ff1,CR->ForAtt,32*2); }; //2.Enemy list RBlockRead(ff1,CT->EnemyList,32*2); //End AI Statements }; LOADMES(ff1); RBlockRead(ff1,&NT->NGidot,4); RBlockRead(ff1,&NT->NFarms,4); //Upgrades information Upgrade* UP=&NT->UPG; RBlockRead(ff1,&UP->NUpgrades,4); for(i=0; i<UP->NUpgrades; i++) { RBlockRead(ff1,&nn,1); UP->utp1[i]->Enabled=nn; RBlockRead(ff1,&UP->utp1[i]->Stage,2); }; //end of upgrade information //General AI statements LOADMES(ff1); RBlockRead(ff1,&NT->CasheSize,4); RBlockRead(ff1,&NT->NationalAI,4); RBlockRead(ff1,&NT->SWP,sizeof NT->SWP); //end of nation loading }; return true; };
void LoadMap(ResFile ff1) { PromptTime=0; MAXOBJECT=0; memset(&fmap[0][0],0,sizeof fmap); memset(Group,0,sizeof Group); memset(&TrMap[0][0],0,sizeof TrMap); memset(&LLock[0][0],0,sizeof LLock); memset(&WLock[0][0],0,sizeof WLock); memset(&WMap[0][0],0,sizeof WMap); memset(&map[0][0],0,sizeof map); memset(NLocks,0,sizeof NLocks); BuildMode=false; for(int i=0; i<maxmap; i++) for(int j=0; j<maxmap; j++) { //map[i][j].BuildingID=65535; Mops[j][i]=65535; Died[j][i]=65535; FlyMops[j][i]=65535; //map[i][j].FlyID=65535; }; RBlockRead(ff1,&i,4); if (i!=0x1B46504D) LOutErr("Incorrect map file format."); LOADMES(ff1); RBlockRead(ff1,&msx,4); RBlockRead(ff1,&msy,4); RBlockRead(ff1,&i,4); RBlockRead(ff1,&i,4); LOADMES(ff1); for(i=0; i<msy; i++) { LOADMES(ff1); RBlockRead(ff1,&tmap[i][0],msx); }; LOADMES(ff1); LoadPackArray(ff1,&Died[0][0],65536); for(i=0; i<msx; i++)for(int j=0; j<msy; j++) { byte k=Locking[tmap[j][i]]; if(k&1) { LLock[i+1][j+1]=1; IncLock(j+1,i+1); TrMap[i+1][j+1]=1; }; //if(k&2)map[j][i].WaterLock=true; }; for(i=0; i<=msx+1; i++) { TrMap[i][0]=2; TrMap[i][msy+1]=2; LLock[i][0]=2; IncLock(0,i); LLock[i][msy+1]=2; IncLock(msy+1,i); WMap[i][0]=2; WMap[i][msy+1]=2; WLock[i][0]=2; WLock[i][msy+1]=2; WMap[i][0]=2; WMap[i][msy+2]=2; WLock[i][0]=2; WLock[i][msy+2]=2; }; for(i=0; i<msy+1; i++) { TrMap[0][i]=2; TrMap[msx+1][i]=2; LLock[0][i]=2; IncLock(i,0); LLock[msx+1][i]=2; IncLock(i,msx+1); WMap[0][i]=2; WMap[msx+1][i]=2; WLock[0][i]=2; WLock[msx+1][i]=2; WMap[0][i]=2; WMap[msx+2][i]=2; WLock[0][i]=2; WLock[msx+2][i]=2; }; //RSCRSizeX=RealLx; //RSCRSizeY=RealLy; //COPYSizeX=RealLx; //smaplx=17; //if(RSCRSizeY==768)smaplx=22; //smaply=smaplx; //smapx=COPYSizeX-(smaplx<<5)-32; //smapy=(RSCRSizeY-(smaply<<5))>>1; //smapx=7*32; //smapy=28; //smaplx=19; //smaply=19; //mapx=1; //mapy=1; //minix=32; //miniy=32; MiniMade=false; //Nsel=0; CreateResMap(); CreateWaterMap(); CreateTZones(); CreateCMap(); InitRenderMap(); };