hedgewars/uMisc.pas
changeset 2715 0e4e0db79e2a
parent 2705 2b5625c4ec16
child 2716 b9ca1bfca24f
equal deleted inserted replaced
2714:c85ffe57d971 2715:0e4e0db79e2a
   117 
   117 
   118 	WaterColorArray	: array[0..3] of HwColor4f;
   118 	WaterColorArray	: array[0..3] of HwColor4f;
   119 
   119 
   120 	CursorPoint	: TPoint;
   120 	CursorPoint	: TPoint;
   121 	TargetPoint	: TPoint;
   121 	TargetPoint	: TPoint;
       
   122 
       
   123     TextureList : PTexture;
   122 
   124 
   123 
   125 
   124 procedure init_uMisc;
   126 procedure init_uMisc;
   125 procedure free_uMisc;
   127 procedure free_uMisc;
   126 procedure movecursor(dx, dy: Integer);
   128 procedure movecursor(dx, dy: Integer);
   346 end;
   348 end;
   347 
   349 
   348 function NewTexture(width, height: Longword; buf: Pointer): PTexture;
   350 function NewTexture(width, height: Longword; buf: Pointer): PTexture;
   349 begin
   351 begin
   350 new(NewTexture);
   352 new(NewTexture);
       
   353 NewTexture^.PrevTexture:= nil;
       
   354 NewTexture^.NextTexture:= nil;
       
   355 if TextureList <> nil then
       
   356     begin
       
   357     TextureList^.PrevTexture:= NewTexture;
       
   358     NewTexture^.NextTexture:= TextureList
       
   359     end;
       
   360 TextureList:= NewTexture;
       
   361 
   351 NewTexture^.w:= width;
   362 NewTexture^.w:= width;
   352 NewTexture^.h:= height;
   363 NewTexture^.h:= height;
   353 NewTexture^.rx:= 1.0;
   364 NewTexture^.rx:= 1.0;
   354 NewTexture^.ry:= 1.0;
   365 NewTexture^.ry:= 1.0;
   355 
   366 
   367 var tw, th, x, y: Longword;
   378 var tw, th, x, y: Longword;
   368     tmpp: pointer;
   379     tmpp: pointer;
   369     fromP4, toP4: PLongWordArray;
   380     fromP4, toP4: PLongWordArray;
   370 begin
   381 begin
   371 new(Surface2Tex);
   382 new(Surface2Tex);
       
   383 Surface2Tex^.PrevTexture:= nil;
       
   384 Surface2Tex^.NextTexture:= nil;
       
   385 if TextureList <> nil then
       
   386     begin
       
   387     TextureList^.PrevTexture:= Surface2Tex;
       
   388     Surface2Tex^.NextTexture:= TextureList
       
   389     end;
       
   390 TextureList:= Surface2Tex;
       
   391 
   372 Surface2Tex^.w:= surf^.w;
   392 Surface2Tex^.w:= surf^.w;
   373 Surface2Tex^.h:= surf^.h;
   393 Surface2Tex^.h:= surf^.h;
   374 
   394 
   375 if (surf^.format^.BytesPerPixel <> 4) then
   395 if (surf^.format^.BytesPerPixel <> 4) then
   376 begin
   396 begin
   435 
   455 
   436 procedure FreeTexture(tex: PTexture);
   456 procedure FreeTexture(tex: PTexture);
   437 begin
   457 begin
   438 if tex <> nil then
   458 if tex <> nil then
   439 	begin
   459 	begin
       
   460     if tex^.NextTexture <> nil then tex^.NextTexture^.PrevTexture:= tex^.PrevTexture;
       
   461     if tex^.PrevTexture <> nil then tex^.PrevTexture^.NextTexture:= tex^.NextTexture
       
   462        else TextureList:= tex^.NextTexture;
   440 	glDeleteTextures(1, @tex^.id);
   463 	glDeleteTextures(1, @tex^.id);
   441 	dispose(tex)
   464 	Dispose(tex)
   442 	end
   465 	end
   443 end;
   466 end;
   444 
   467 
   445 function DecodeBase64(s: shortstring): shortstring;
   468 function DecodeBase64(s: shortstring): shortstring;
   446 const table = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
   469 const table = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
   553 var i: LongInt;
   576 var i: LongInt;
   554 begin
   577 begin
   555 	cDrownSpeed.QWordValue	:= 257698038;		// 0.06
   578 	cDrownSpeed.QWordValue	:= 257698038;		// 0.06
   556 	cMaxWindSpeed.QWordValue:= 2147484;		// 0.0005
   579 	cMaxWindSpeed.QWordValue:= 2147484;		// 0.0005
   557 	cWindSpeed.QWordValue	:= 429496;		// 0.0001
   580 	cWindSpeed.QWordValue	:= 429496;		// 0.0001
   558 	cGravity		:= cMaxWindSpeed;
   581 	cGravity                := cMaxWindSpeed;
   559 	cDamageModifier		:= _1;
   582 	cDamageModifier         := _1;
   560 	TargetPoint		:= cTargetPointRef;
   583 	TargetPoint             := cTargetPointRef;
       
   584     TextureList             := nil;
   561 	
   585 	
   562 	// int, longint longword and byte
   586 	// int, longint longword and byte
   563 	CursorMovementX		:= 0;
   587 	CursorMovementX		:= 0;
   564 	CursorMovementY		:= 0;
   588 	CursorMovementY		:= 0;
   565 	GameTicks		:= 0;
   589 	GameTicks		:= 0;
   663 
   687 
   664 end;
   688 end;
   665 
   689 
   666 procedure free_uMisc;
   690 procedure free_uMisc;
   667 begin
   691 begin
       
   692 while TextureList <> nil do FreeTexture(TextureList);
   668 //uRandom.DumpBuffer;
   693 //uRandom.DumpBuffer;
   669 
   694 
   670 {$IFDEF DEBUGFILE}
   695 {$IFDEF DEBUGFILE}
   671 writeln(f, 'halt at ', GameTicks, ' ticks. TurnTimeLeft = ', TurnTimeLeft);
   696 writeln(f, 'halt at ', GameTicks, ' ticks. TurnTimeLeft = ', TurnTimeLeft);
   672 flush(f);
   697 flush(f);