6112 TCP UDP dtspcd, execute commands and launch applications remotely, Official
6112 TCP Blizzard's Battle.net gaming service and some games, ArenaNet gaming service, Relic gaming service, Unofficial
6112 TCP Club Penguin Disney online game for kids, Unofficial
[url]http://www.youtube.com/watch?v=JEGgUTVsl7k[/url] ([url]http://www.youtube.com/watch?v=JEGgUTVsl7k[/url])
there is one WC2 mod that is head and shoulders above everything else absolutely screaming out to be implimented.
The most I've gotten to is war2 sitting at black screen when I used my maps bigger then 128x128. I think I nulled out the minimap and it no longer crashed. But I was stuck there and clueless. What do you think about that?
I think you gave up to soon ;)
Nah I just ran out of time because of career changes. Plus tons of other projects kept me bottlenecked. All honestly I was tired of being the one trying.
....buffers have overflowed and corrupted .data or .data? section values...
.data?
mapArray db 4000h dup (?) ;-- some map array or other
hGLthing dd ? ;-- handle to some important GL structure
otherStuff dd ?,?,?,? ;-- all sorts of other important data
.data?
ptrMapArray dd ? ;-- *POINTER* to some map array or other
hGLthing dd ? ;-- handle to some important GL structure
otherStuff dd ?,?,?,? ;-- all sorts of other important data
.code
push 4000h
call GlobalAlloc
mov ptrMapArray,eax ; <-- functions return values in the eax register
so this just asks the OS to allocate space for the array then just stores a pointer to the allocated memory in the data section. Later when the program wants to access this array you might see something like:mov edi,ptrMapArray
; ...... then further on
mov [edi+ebx],dl ; ... or whatever
in this case edi woud contain the pointer to the base address of the array, ebx would contain an offset into the array, and the low byte of edx would contain the value it is writing there.mov edi,ptrMapArray
has become maybe:mov edi,[4A789Ch]
... where 0x4A789C is the actual address of that dword in the .data? section (this is what the linker does)call GlobalAlloc
will still be there because GlobalAlloc is exported by name from kernel32.dll and the disassembler will extract the proc name from the IMAGE_EXPORT_DIRECTORY structure in kernel32.push 4000h ; (128x128)
call GlobalAlloc
to:push 10000h ; (256x256)
call GlobalAlloc
mapArray db 4000h dup (?)
to:mapArray db 10000h dup (?)
then recompile and its done (approx. 5 seconds total).data?
hGLthing dd ?
this just allocates 4 bytes in the .data? section and names that location "hGLthing " mapArray db 4000h dup (?)
'dup' means duplicate. Its declaring bytes (db) and its declaring 0x4000 of them..data
dwThisVar dd 0FE339D2h
myByte db 20h
thisString db "Hello World",0 ; <-- an initialised zero terminated string
myWords dw 3,3,3,3 ; <-- 4 words all set to 3 (8 bytes all up)
ymWords dw 4 dup (3) ; <-- exactly the same ( 4 words all set to 3 )
D2:39:E3:0F:
20:
48:65:6C:6C:6F:20:57:6F:72:6C:64:00
03:00:03:00:03:00:03:00:
03:00:03:00:03:00:03:00:
(off the to of my head - dont crucify me if I messed up, but you get the idea..)sub esp,4
but it is vital to ensure that the stack is 'balanced' - returned to its correct state before executing the next 'ret' - return instruction. In this case you couldadd esp,4
or justpop eax
which would get the value off the stack and put it in the eax register. (push and pop automatically adjust the esp register). The other way to do this is to save the value of esp when you enter a procedure. push ebp ; save the value in esp
mov ebp,esp ; use ebp to store the current stack pointer
sub esp,8 ; in this case 8 bytes of local storage has been allocated for the proc (most likely 2 DWORDS)
At this point the arguments that were passed to the procedure are also sitting on the stack behind the return address that was left there by the call instruction that called the proc and the original value of ebp, which we have just stored there. ebp holds the value of the stack pointer after this proc entry, so if it is not changed the passed arguments can be accessed directly using ebp provided we allow for the 8 bytes that these 2 DWORD values use, so the first argument can be accessed at [ebp+8] and assuming its a DWORD (which they almost always are) the second argument is at [ebp+0Ch] etc. At the same time the locals that were allocated with thesub esp,8
can be accessed at [ebp-4] and [ebp-8]. This area of the stack, from the start of the passed arguments to the end of any local allocations, for the life of the proc is often referred to as the stack frame for that procedure.mov esp,ebp ; <-- restore the stack pointer from the base pointer
pop ebp ; <-- pop the base pointer value off the stack
ret ; <-- pop the return address off the stack and jmp to that location
In actual fact, Mr Gates made such extensive use of this method that his mates at Intel eventually designed their CPUs with special instructions to acommodate it. The leave instruction does the combination of mov esp,ebp and pop ebp in one hit.mov esp,ebp ; <-- restore the stack pointer from the base pointer
pop ebp ; <-- pop the base pointer value off the stack
retn 8 ; <-- pop the return address off the stack, add 8 to esp, then jmp to that address
OR...leave <-- do the esp/ebp square dance
retn 8 ; <-- pop the return address off the stack, add 8 to esp, then jmp to that address
would it be possible to use the lat trick for multiple players? i've only ever tried in 1v1 .. But theoretically if ...........
...... you're talking about our ping in relation to the server.war2.ru.. what about /ping (specific player) .. the number shot back at me is the time it takes in milliseconds for our computers to communicate with eachother, correct? so, a player with a ping of 3500 vs 350 is going to make a noticable difference in game.....
so for the bonus question .. .....the only things i can come up with is somehow form a TCP connection (even if only temporarily) with all of the players on the server so you auto-send/recieve UDP traffic to those players after that .. or somehow, when you first log onto the server and successfully send/receive UDP packets to the server, have the server forward your UDP packets to all other players on the server so there is a "connection"........
....and for the extra bonus points... WHO WAS PAYING ATTENTION? - What small change could have been made to the battle.net protocol to eliminate the whole "opening ports" to host a game issue?
The problem is with that very first "I want to join" message that your client sends to the game host.
.. you're talking about our ping in relation to the server.war2.ru.. what about /ping (specific player) .. the number shot back at me is the time it takes in milliseconds for our computers to communicate with eachother, correct? so, a player with a ping of 3500 vs 350 is going to make a noticable difference in game
What is the logic behind "conflicts?" There's a game up and either Player A or Player B can join the game and it doesn't lag, but if both are in, it does.
Lag,(or lack of it) is a function of the peer-to-peer UDP times... or more to the point the worst peer-to-peer route between any two players in the game
The underpinning logic of the internet, and therefore the internet protocol is that any router can get a packet intended for any address and send it in the right direction to get there... and the next router (server... whatever) will do the same, until the packet eventually gets where its going.
Damn! :)
Okay so their is a referenced string for display adapter you can find with cheat engine, etc. Change that also!
Also another tip! Try to hex ddraw.dll!
HRESULT SetDisplayMode(
dwWidth,
dwHeight,
dwBPP,
dwRefreshRate,
dwFlags );
There's a few calls to GetDesktopWindow followed by GetDC, this gets the device context of the windows desktop (being the top level window), so it looks like its, in effect just resizing the desktop to 640x480 then writing directly to it. Possibly. At lot of it relates to dialog boxes and stuff, hard to tell without spending more time.
you, sir, are an actual gentleman. thank you very much bro. not actually putting in a range might do the trick, will get stuck into this when i sober up in the mornin. thanks again
speed i still havent found it.
but attacks can be changed and range.
Yeah, can you share that map editor?
As i see, a C++ class/library to include into war2 loader.
Just thouhgt: would be great to find good network programmer/engineer for war2 project:
We could handle the whole war2 network behavior ourselves: to guarantee all the UDP connections between all the cilents, to manage and find optimal routes for that connections
reroute if clients will suddenly change their IP during the game.I think this would be a very rare event.
UDP over internet is far from perfect and has lots problems. So, some kind of layer between raw war2 UDP and internet (like distributed UDP network between war2 clients) based on new technologies and implementation is what we need.
An IP packet:
{version, size, protocol, src address, dst address, {Payload - 'size' bytes of data}}
Transport Layer:
UDP Packet:
{src port, dst port, size, checksum, {Payload - 'size' bytes of data}}
TCP Packet:
{src port, dst port, sequence number, size, checksum, {Payload - 'size' bytes of data}}
{version, size1, 0x11, src address, dst address, {src port, dst port, size2, checksum, {Payload - 'size2' bytes of data}}}
Here size1 is the size of the entire UDP packet, which is the payload for the IP packet, and size2 is the size of the data which is the payload for the UDP packet.
{version, size1, 0x06, src address, dst address, {src port, dst port, X , size2, checksum, {Payload - 'size2' bytes of data}}}
hobby ;)Heh... ya I've just been looking up some info from old posts. I collect em here so I don't have to search next time... but OMG that lambchops goes on a bit doesn't he? Every time I look for some thingy I find another I find another 6 pages of his drivel ;D
MM UNITS
--------------------------
RED D0 D0-D3
BLUE 01 * D4-D7
TEAL D8 D8-DB
PURP DC DC-DF
OJ E0 E0-E3
BLACK E4 E4-E7
WHITE FF * E8-EB
YELLOW 02 * 0C-0F
Very nice follow through lamb. I love it. The gray looks good!
Just looks black in game for some reason
Was able to recreate the hexing of the .exe file, i am curious on how you know which binary held the mini map file?
RED D0 D0-D3
BLUE 01 * D4-D7
TEAL D8 D8-DB
PURP DC DC-DF
OJ E0 E0-E3
BLACK E4 E4-E7
WHITE FF * E8-EB
YELLOW 02 * 0C-0F
:-*
Now I wonder if he individually changed the palette of each bmp or if this is also in the war2.exe.. I will be looking at it tonight.
The only reason I ask is i want to learn. I would like to change the black ogres as well possibly some of the colors to dif variations.
It also opens the door for a bigger player Warcraft 2, such as 10 players or 12 players. Sc2 and wc3 both do it. I just wonder if it's the engine holding it back as well.
I know some of the guys have looked into it already. And say it's impossible for a bigger map than 128x128
Intense writeup as usual. Yes I edited the wardat.mpq and extracted the separate grps into an edit folder. I than changed the peon004 image to use green instead of black in the palette. I then used grp edit, loaded the peon grp, deleted the frame 4 and replaced with my new frame 4 with green over black. I save tried to play and gave me error... the thing is, the war2patch file is the only one downloaded through the change. So I'm not sure if it's more of a .ppl file which I have no editor for or if it's maybe a table file(which I thought was only for text like campaign or bnet graphic changes) unless it's simply in the forest file?? Which is also changed in the black to pink war2patch, in that case o would have to edit the tile palette...
And yes im obsessed.and I do like the trigger ideas, the game could develop further in the custom games that way.
but u can still do this!!
take your ass to bed!
car blew a head gasket :oI hate that my Monte Carlo went out like a champ! The fucker would over heat and I would pull over and put a rag over this metal tube and push a screw driver to release all the air building up. Then I would be good for another day! Sadly I sold that bitch for a grand :, ( the mechanic I sold it to fixed it for like 300 and did 24 hours worth of work :) lucky dude!
So you need to make a sheet up for the animation file. And it's restricted to 8 bit 64 colors?
Thought you could string images together in a grp file.
If anyone is interested, its like a hue'd lime green instread of the Pink.
smurfs!!
very cool man!
smurfs!!
[url]http://imagizer.imageshack.us/v2/516x387q90/923/Im3GD2.jpg[/url] ([url]http://imagizer.imageshack.us/v2/516x387q90/923/Im3GD2.jpg[/url])
....was gonna make war2 play on it but got side tracked .....got my controllers hooked up to it and mario kart going sucesss!!!!!
Avira reports a false positive "TR/Crypt.ULPM.Gen" with your ss grabber can you do something about it? :D
Avira (no cloud) TR/Crypt.ULPM.Gen 20170306
Arcabit Trojan.Heur.emGfXPgbohm 20170306
BitDefender Gen:Trojan.Heur.emGfXPgbohm 20170306
Emsisoft Gen:Trojan.Heur.emGfXPgbohm (B) 20170306
F-Secure Gen:Trojan.Heur.emGfXPgbohm 20170306
GData Gen:Trojan.Heur.emGfXPgbohm 20170306
eScan Gen:Trojan.Heur.emGfXPgbohm 20170306
Endgame malicious (high confidence) 20170222
CrowdStrike Falcon (ML) malicious_confidence_68% (D) 20170130
Invincea worm.win32.bartly.a 20170203
McAfee-GW-Edition BehavesLike.Win32.Sality.lc 20170306
Qihoo-360 HEUR/QVM18.1.0000.Malware.Gen 20170306
TheHacker Posible_Worm32 20170305
ALYac 20170306
AVG 20170306
AVware 20170306
AegisLab 20170306
AhnLab-V3 20170306
Alibaba 20170228
Antiy-AVL 20170306
Avast 20170306
Baidu 20170306
Bkav 20170306
CAT-QuickHeal 20170306
CMC 20170306
ClamAV 20170306
Comodo 20170306
Cyren 20170306
DrWeb 20170306
ESET-NOD32 20170306
F-Prot 20170306
Fortinet 20170306
Ikarus 20170306
Jiangmin 20170306
K7AntiVirus 20170306
K7GW 20170306
Kaspersky 20170306
Kingsoft 20170306
Malwarebytes 20170306
McAfee 20170306
Microsoft 20170306
NANO-Antivirus 20170306
Panda 20170306
Rising 20170306
SUPERAntiSpyware 20170306
Sophos 20170306
Symantec 20170306
Tencent 20170306
TrendMicro 20170306
TrendMicro-HouseCall 20170306
Trustlook 20170306
VBA32 20170306
VIPRE 20170306
ViRobot 20170306
Webroot 20170306
WhiteArmor 20170303
Yandex 20170225
Zillya 20170304
ZoneAlarm by Check Point 20170306
Zoner 20170306
nProtect 20170306
d sorry for triggering you to write so much
smurfs!!
[url]http://imagizer.imageshack.us/v2/516x387q90/923/Im3GD2.jpg[/url] ([url]http://imagizer.imageshack.us/v2/516x387q90/923/Im3GD2.jpg[/url])
hooooooooly shit, Lamby, you made the big ss thing!
oops. just noticed the player names aren't the right colors. :( I'll fix that shortly.
I am a huge scrub
and need help Lamby.
I opened the app then went to single player custom scenario and pressed F6 key and it did the scrolling around thing & saved the file as .png but it's 0kb. halp
The original version that saves a bmp works though (after I figured out that having a 2nd monitor makes it do odd things... :D)
actually they're still coming out goofy without 2nd monitor (I thought it worked right at one point though)
I noticed crazy eights ss was buggy too
Class ID : {557cf400-1a04-11d3-9a73-0000f81ef32e}
Format ID : {b96b3cab-0728-11d3-9d7b-0000f81ef32e}
Codec : Built-in BMP Codec
Module :
Description: BMP
File Types : *.BMP;*.DIB;*.RLE
MIME Type : image/bmp
-------------------------------------------
Class ID : {557cf401-1a04-11d3-9a73-0000f81ef32e}
Format ID : {b96b3cae-0728-11d3-9d7b-0000f81ef32e}
Codec : Built-in JPEG Codec
Module :
Description: JPEG
File Types : *.JPG;*.JPEG;*.JPE;*.JFIF
MIME Type : image/jpeg
-------------------------------------------
Class ID : {557cf402-1a04-11d3-9a73-0000f81ef32e}
Format ID : {b96b3cb0-0728-11d3-9d7b-0000f81ef32e}
Codec : Built-in GIF Codec
Module :
Description: GIF
File Types : *.GIF
MIME Type : image/gif
-------------------------------------------
Class ID : {557cf405-1a04-11d3-9a73-0000f81ef32e}
Format ID : {b96b3cb1-0728-11d3-9d7b-0000f81ef32e}
Codec : Built-in TIFF Codec
Module :
Description: TIFF
File Types : *.TIF;*.TIFF
MIME Type : image/tiff
-------------------------------------------
Class ID : {557cf406-1a04-11d3-9a73-0000f81ef32e}
Format ID : {b96b3caf-0728-11d3-9d7b-0000f81ef32e}
Codec : Built-in PNG Codec
Module :
Description: PNG
File Types : *.PNG
MIME Type : image/png
Class ID : {557cf400-1a04-11d3-9a73-0000f81ef32e}
Format ID : {b96b3cab-0728-11d3-9d7b-0000f81ef32e}
Codec : Built-in BMP Codec
Module :
Description: BMP
File Types : *.BMP;*.DIB;*.RLE
MIME Type : image/bmp
-------------------------------------------
Class ID : {557cf401-1a04-11d3-9a73-0000f81ef32e}
Format ID : {b96b3cae-0728-11d3-9d7b-0000f81ef32e}
Codec : Built-in JPEG Codec
Module :
Description: JPEG
File Types : *.JPG;*.JPEG;*.JPE;*.JFIF
MIME Type : image/jpeg
-------------------------------------------
Class ID : {557cf402-1a04-11d3-9a73-0000f81ef32e}
Format ID : {b96b3cb0-0728-11d3-9d7b-0000f81ef32e}
Codec : Built-in GIF Codec
Module :
Description: GIF
File Types : *.GIF
MIME Type : image/gif
-------------------------------------------
Class ID : {557cf405-1a04-11d3-9a73-0000f81ef32e}
Format ID : {b96b3cb1-0728-11d3-9d7b-0000f81ef32e}
Codec : Built-in TIFF Codec
Module :
Description: TIFF
File Types : *.TIF;*.TIFF
MIME Type : image/tiff
-------------------------------------------
Class ID : {557cf406-1a04-11d3-9a73-0000f81ef32e}
Format ID : {b96b3caf-0728-11d3-9d7b-0000f81ef32e}
Codec : Built-in PNG Codec
Module :
Description: PNG
File Types : *.PNG
MIME Type : image/png
it's glorious, ty lamby!!!
(Beetle Island people, great chaotic map!)
Assuming single player mode.
Map Dimensions 128x128
Image aquired in 0.09 seconds
Check/re-aquire in 0.06 seconds
GdiplusStartup returned Ok
GdipGetImageEncodersSize returned Ok
GdipGetImageEncoders returned Ok
GdipCreateBitmapFromGdiDib returned Ok
GdipSaveImageToFile returned Ok
GdipDisposeImage returned Ok
GdiplusShutdown returned Ok
Checking GDI+ output
GDI+ confirmed OK
GDI+ check/Save (png) 0.36 sec
Complete. Total Time 0.52 seconds
Assuming single player mode.
Map Dimensions 128x128
Image aquired in 0.09 seconds
Check/re-aquire in 0.06 seconds
GdiplusStartup returned Ok
GdipCreateBitmapFromGdiDib returned Ok
GdipSaveImageToFile returned Ok
GdipDisposeImage returned Ok
GdiplusShutdown returned Ok
Save (png) 0.16 sec
Complete. Total Time 0.31 seconds
Maybe some programmer should change the ports in the files from war2 : instead 6112-6119 make it on a port range which are usually open.
That could help a lot for all !!!
lamb your back! :-*Hehe :) ya I'm around, just stupid RL cramping my style a bit.
Hey :)
Sorry I've been MIA for a few days, thanks for posting that output.
Have made a self checking version ([url]http://forum.war2.ru/index.php?action=dlattach;topic=2703.0;attach=1162[/url]).
It takes a SS then goes back through every screen in reverse order and gets it again, then checks if it's the same as the one from the first pass. If anything doesn't match it gets that screen again taking extra time/precautions and hopefully making sure that it has the right image. It's hard to tell because it just never fails on my machine.
Please try it out. It will also produce a small text file called "SSgrab.txt" that will look something like this:Code: [Select]Assuming single player mode.
Map Dimensions 128x128
Image aquired in 0.09 seconds
Check/re-aquire in 0.06 seconds
GdiplusStartup returned Ok
GdipGetImageEncodersSize returned Ok
GdipGetImageEncoders returned Ok
GdipCreateBitmapFromGdiDib returned Ok
GdipSaveImageToFile returned Ok
GdipDisposeImage returned Ok
GdiplusShutdown returned Ok
Checking GDI+ output
GDI+ confirmed OK
GDI+ check/Save (png) 0.36 sec
Complete. Total Time 0.52 seconds
Assuming single player mode.
Map Dimensions 128x128
Image aquired in 0.09 seconds
Check/re-aquire in 0.06 seconds
GdiplusStartup returned Ok
GdipCreateBitmapFromGdiDib returned Ok
GdipSaveImageToFile returned Ok
GdipDisposeImage returned Ok
GdiplusShutdown returned Ok
Save (png) 0.16 sec
Complete. Total Time 0.31 seconds
Which should help me track down why the PNG save is failing, if you can please post the results.
Assuming single player mode.
Map Dimensions 128x128
Image aquired in 0.87 seconds
Screen check fail (114,114)... reaquiring
Check/re-aquire in 1.25 seconds
GdiplusStartup returned Ok
GdipGetImageEncodersSize returned Ok
GdipGetImageEncoders returned Ok
GdipCreateBitmapFromGdiDib returned Ok
GdipSaveImageToFile returned InvalidParameter
GdipDisposeImage returned Ok
GdiplusShutdown returned Ok
Checking GDI+ output
GDI+ Error - reverting to BMP output.
bitmap saved to SS_Cliffhanger BNE - 20170321-125412.bmp
GDI+ check/Save (png) 0.23 sec
Complete. Total Time 2.37 seconds
Assuming single player mode.
Map Dimensions 128x128
Image aquired in 0.81 seconds
Screen check fail (14,14)... reaquiring
Check/re-aquire in 1.22 seconds
bitmap saved to SS_Cliffhanger BNE - 20170321-125524.bmp
Save (png) 0.00 sec
Complete. Total Time 2.04 seconds
ok done! I think it's perfect this time? *tentatively hopeful*
"GdipSaveImageToFile returned InvalidParameter"
that works great, ty! c:
Nice edit to the tutorial. It's almost a sprite editors if you could load up a bmp with say 60 frames or scroll on it. Really good
If u want make map with "blizzard icon" you need add at end"..SIGN......"
If u want make map with "ladder icon" you need replace TYPE...WAR2 MAP..˙",ć "VER ....DESC ... into "D˝’Ş"
If u want make map with "blizzard icon" you need add at end"..SIGN......"
If u want make map with "ladder icon" you need replace TYPE...WAR2 MAP..˙",ć "VER ....DESC ... into "D˝’Ş"
Ok cool. Thanks for the info @Szwagier
Im actually playing with making a new map editor at the moment. IDK if I'll end up having time to finish it, but it's an interesting project.
([url]http://forum.war2.ru/index.php?action=dlattach;topic=2703.0;attach=2090[/url])
It's so beautiful!! 😢😢
:o :o :o :o :o :o :o awesome .....how about a "tile part" in the pud a little mem editor can load peoples custom tiles???
It's so beautiful!! 😢😢
Yeah it's pretty. Doesn't do very much yet though but I think I've got the bulk of the tricky bits out of the way.
Got the other 3 tilesets and unit colors working yesterday :) It's interesting to watch a particular view switch from forest to winter to swamp and compare... never noticed before but AFAIK there's actually no existing way to do this.
([url]http://forum.war2.ru/index.php?action=dlattach;topic=2703.0;attach=2092[/url])
What amazes me the most is how you can read the .pud and display the tiles correctly, units, and buildings. I can do unit data, stats, etc... just nothing with graphics.... I think you should add your offset editor to this map editor for more power ofcourse!! :) good job man keep it comming!
ok i tried discover where is mission objectiveIt's hardcoded in the exe I made a thread about this over a year ago. For people to have different missions or objectives they would need to run a program or everyone downloads a patched war2.exe...
when i copied first mission from DP xhum01 and saved as xhum02 i could kill alleria and turyalon, i couldnt kill danath
if i copied first mission human1 from TD and saved as xhum01 i got lose after 5 sec. SO mission objective are not in map
but
when i moved first mission human1 and played in scenario i wont win when i kill enemy units i will win when i made 4 farms and 1 rax so this is in map
Yes i remember but question is why mission 1 is working in scenario alsook i tried discover where is mission objectiveIt's hardcoded in the exe I made a thread about this over a year ago. For people to have different missions or objectives they would need to run a program or everyone downloads a patched war2.exe...
when i copied first mission from DP xhum01 and saved as xhum02 i could kill alleria and turyalon, i couldnt kill danath
if i copied first mission human1 from TD and saved as xhum01 i got lose after 5 sec. SO mission objective are not in map
but
when i moved first mission human1 and played in scenario i wont win when i kill enemy units i will win when i made 4 farms and 1 rax so this is in map
when i moved first mission human1 and played in scenario i wont win when i kill enemy units i will win when i made 4 farms and 1 rax so this is in map
All Maps from camping are Saved as pus
Pud file as normalnie map Saved human01. Pud like gardenofwar. Pud
OK now i know what happen i made farm rescue(passive) , if i wont acctive it, it means its opponent, if I destroy it with range (archers,cata etc) without touch it i will win
[url]http://forum.war2.ru/index.php/topic,1956.0.html[/url] ([url]http://forum.war2.ru/index.php/topic,1956.0.html[/url])
It is possible to change? for example make 6 farms not 4?
anyway i tried with cheat enigne and i could change only res
Yes, you could do that but I think it would be a pain IN the ass to locate that offset. Look for a map that has more objectives in common, like build 1 shipyard, etc... the more you can change the better you can search.
It is possible to change? for example make 6 farms not 4?
anyway i tried with cheat enigne and i could change only res
Yes its in exe, but how do that cause u need Save exe with New value, i tired to do it but w2 didnt turn on
00 00 00 00 00 00 00 00 90 24 44 00 F0 25 44 00 00 00 00 00 A0 26 44 00 D0 28 44 00 80 29 44 00 E0 29 44 00 90 2A 44 00 20 2B 44 00 E0 2B 44 00 60 2C 44 00 F0 2C 44 00 80 2D 44 00 90 2E 44 00 C0 32 44 00 30 33 44 00 E0 33 44 00 80 34 44 00 u see them mem address the exe tells you swithc them up
Warcraft II BNE.exe - PE Image Information Lambchops 2002-2017
----------------------------------------
IMAGE_DOS_HEADER - SIZE: 62
e_magic 0x5A4D
e_cblp 0x0090
e_cp 0x0003
e_crlc 0x0000
e_cparhdr 0x0004
e_minalloc 0x0000
e_maxalloc 0xFFFF
e_ss 0x0000
e_sp 0x00B8
e_csum 0x0000
e_ip 0x0000
e_cs 0x0000
e_lfarlc 0x0040
e_ovno 0x0000
e_res_1 0x0000
e_res_2 0x0000
e_res_3 0x0000
e_res_4 0x0000
e_oemid 0x0000
e_oeminfo 0x0000
e_res2_1 0x0000
e_res2_2 0x0000
e_res2_3 0x0000
e_res2_4 0x0000
e_res2_5 0x0000
e_res2_6 0x0000
e_res2_7 0x0000
e_res2_8 0x0000
e_res2_9 0x0000
e_res2_A 0x0000
e_lfanew 0x00E8
----------------------------------------
IMAGE_SIGNATURE - SIZE: 4
Signature 0x00004550
----------------------------------------
IMAGE_FILE_HEADER - SIZE: 20
Machine 0x014C
NumberOfSections 0x0004
TimeDateStamp 0x3B01973F
PointerToSymbolTable 0x00000000
NumberOfSymbols 0x00000000
SizeOfOptionalHeader 0x00E0
Characteristics 0x010F
----------------------------------------
IMAGE_OPTIONAL_HEADER - SIZE: 96
Magic 0x010B
MajorLinkerVersion 0x06
MinorLinkerVersion 0x00
SizeOfCode 0x0008F000
SizeOfInitializedData 0x0004B000
SizeOfUninitializedData 0x00000000
AddressOfEntryPoint 0x0007DC88
BaseOfCode 0x00001000
BaseOfData 0x00090000
ImageBase 0x00400000
SectionAlignment 0x00001000
FileAlignment 0x00001000
MajorOperatingSystemVersion 0x0004
MinorOperatingSystemVersion 0x0000
MajorImageVersion 0x0000
MinorImageVersion 0x0000
MajorSubsystemVersion 0x0004
MinorSubsystemVersion 0x0000
Reserved1 0x00000000
SizeOfImage 0x000DB000
SizeOfHeaders 0x00001000
CheckSum 0x00000000
Subsystem 0x0002
DllCharacteristics 0x0000
SizeOfStackReserve 0x00100000
SizeOfStackCommit 0x00001000
SizeOfHeapReserve 0x00100000
SizeOfHeapCommit 0x00001000
LoaderFlags 0x00000000
NumberOfRvaAndSizes 0x00000010
----------------------------------------
IDD# 2 [ IMPORT ]
IMAGE_DATA_DIRECTORY - SIZE: 8
VirtualAddress 0x0009208C
Size 0x000000B4
IDD# 3 [ RESOURCE ]
IMAGE_DATA_DIRECTORY - SIZE: 8
VirtualAddress 0x000D9000
Size 0x00001210
IDD# 13 [ IMPORT ADDRESS ]
IMAGE_DATA_DIRECTORY - SIZE: 8
VirtualAddress 0x00090000
Size 0x000004E8
----------------------------------------
IMAGE_SECTION_HEADER - SIZE: 40
Name .text
VirtualSize 0x0008E2EE
VirtualAddress 0x00001000
SizeOfRawData 0x0008F000
PointerToRawData 0x00001000
PointerToRelocations 0x00000000
PointerToLinenumbers 0x00000000
NumberOfRelocations 0x0000
NumberOfLinenumbers 0x0000
Characteristics 0x60000020
- CNT_CODE
- MEM_EXECUTE
- MEM_READ
----------------------------------------
IMAGE_SECTION_HEADER - SIZE: 40
Name .rdata
VirtualSize 0x00003420
VirtualAddress 0x00090000
SizeOfRawData 0x00004000
PointerToRawData 0x00090000
PointerToRelocations 0x00000000
PointerToLinenumbers 0x00000000
NumberOfRelocations 0x0000
NumberOfLinenumbers 0x0000
Characteristics 0x40000040
- CNT_INITIALIZED_DATA
- MEM_READ
----------------------------------------
IMAGE_SECTION_HEADER - SIZE: 40
Name .data
VirtualSize 0x000445B0
VirtualAddress 0x00094000
SizeOfRawData 0x00018000
PointerToRawData 0x00094000
PointerToRelocations 0x00000000
PointerToLinenumbers 0x00000000
NumberOfRelocations 0x0000
NumberOfLinenumbers 0x0000
Characteristics 0xC0000040
- CNT_INITIALIZED_DATA
- MEM_READ
- MEM_WRITE
----------------------------------------
IMAGE_SECTION_HEADER - SIZE: 40
Name .rsrc
VirtualSize 0x00001210
VirtualAddress 0x000D9000
SizeOfRawData 0x00002000
PointerToRawData 0x000AC000
PointerToRelocations 0x00000000
PointerToLinenumbers 0x00000000
NumberOfRelocations 0x0000
NumberOfLinenumbers 0x0000
Characteristics 0x40000040
- CNT_INITIALIZED_DATA
- MEM_READ
----------------------------------------
IMAGE_IMPORT_DESCRIPTOR - SIZE: 20
Characteristics 0x0009235C
TimeDateStamp 0x00000000
ForwarderChain 0x00000000
Name 0x00092628
FirstThunk 0x0009021C
----------------------------------------
Imported from Storm.dll
Hint Function
-----------------------
Ord0077
Ord006D
Ord0082
Ord0073
Ord008A
Ord006A
Ord0075
Ord0078
Ord007B
Ord0066
Ord007A
Ord0079
Ord0080
Ord007F
Ord01CE
Ord01EB
Ord0086
Ord01F6
Ord0193
Ord01FC
Ord0070
Ord006B
Ord0182
Ord0185
Ord0189
Ord0186
Ord0181
Ord017F
Ord013A
Ord008B
Ord01A9
Ord00CE
Ord00D3
Ord00D8
Ord01AF
Ord00DD
Ord01B2
Ord01BD
Ord007D
Ord0071
Ord00DE
Ord0165
Ord015A
Ord00D0
Ord0143
Ord0145
Ord010D
Ord0109
Ord01CF
Ord0112
Ord0117
Ord01A5
Ord01A8
Ord01AC
Ord01EE
Ord0110
Ord01D1
Ord010B
Ord0108
Ord0113
Ord0114
Ord008C
Ord0100
Ord023B
Ord00FF
Ord0102
Ord0164
Ord0139
Ord0162
Ord015E
Ord01AA
Ord015F
Ord01D4
Ord0191
Ord01F5
Ord01FA
Ord01F7
Ord01FD
Ord023C
Ord0072
Ord00FC
Ord010A
Ord00FD
Ord010C
Ord01A6
Ord0089
Ord01CA
Ord01C9
Ord01C6
Ord01A7
Ord0101
Ord0105
Ord01C5
Ord0104
Ord01C3
----------------------------------------
----------------------------------------
IMAGE_IMPORT_DESCRIPTOR - SIZE: 20
Characteristics 0x00092198
TimeDateStamp 0x00000000
ForwarderChain 0x00000000
Name 0x00092D96
FirstThunk 0x00090058
----------------------------------------
Imported from KERNEL32.dll
Hint Function
-----------------------
0109: GetCurrentProcess
0298: SetHandleCount
0168: GetStdHandle
01E5: LocalAlloc
018E: GetVersion
0230: RaiseException
0125: GetFileSize
00DE: GetComputerNameA
0030: CreateDirectoryA
0293: SetFileAttributesA
028D: SetEnvironmentVariableA
0025: CompareStringW
0024: CompareStringA
028C: SetEndOfFile
00B9: FlushFileBuffers
02A8: SetStdHandle
02EE: VirtualAlloc
0295: SetFilePointer
016C: GetStringTypeW
0169: GetStringTypeA
02F1: VirtualFree
01B6: HeapCreate
01B8: HeapDestroy
018F: GetVersionExA
011C: GetEnvironmentVariableA
0128: GetFileType
011B: GetEnvironmentStringsW
0119: GetEnvironmentStrings
00C2: FreeEnvironmentStringsW
00C1: FreeEnvironmentStringsA
0257: RtlUnwind
01BE: HeapSize
01BD: HeapReAlloc
0146: GetOEMCP
00C9: GetACP
00CF: GetCPInfo
02CB: TerminateProcess
01B4: HeapAlloc
02DB: UnhandledExceptionFilter
02D2: TlsGetValue
029C: SetLastError
02D0: TlsAlloc
01BA: HeapFree
01DD: LCMapStringW
01DC: LCMapStringA
0202: MultiByteToWideChar
0301: WideCharToMultiByte
008C: ExitProcess
01CB: InterlockedIncrement
0166: GetStartupInfoA
008D: ExitThread
02D3: TlsSetValue
010C: GetCurrentThreadId
004D: CreateThread
026C: SetConsoleCtrlHandler
012F: GetLocalTime
0186: GetTickCount
0138: GetModuleFileNameA
005C: DeleteFileA
009F: FindClose
00AC: FindNextFileA
00A3: FindFirstFileA
012D: GetLastError
00DA: GetCommandLineA
0117: GetDriveTypeA
0132: GetLogicalDriveStringsA
001E: CloseHandle
0037: CreateFileA
02C3: Sleep
01C5: InitializeCriticalSection
005A: DeleteCriticalSection
0153: GetProcAddress
01DF: LoadLibraryA
0290: SetEvent
01DE: LeaveCriticalSection
006F: EnterCriticalSection
0252: ResetEvent
02FD: WaitForSingleObject
0034: CreateEventA
02FB: WaitForMultipleObjects
023D: ReadFile
0263: SetCommState
00D8: GetCommState
0264: SetCommTimeouts
01E9: LocalFree
0174: GetSystemTime
00C3: FreeLibrary
0147: GetOverlappedResult
030E: WriteFile
01D0: IsBadReadPtr
013A: GetModuleHandleA
02F6: VirtualQuery
0332: lstrcpynA
01D3: IsBadWritePtr
00BE: FormatMessageA
02B8: SetUnhandledExceptionFilter
01A8: GlobalMemoryStatus
0113: GetDiskFreeSpaceA
0172: GetSystemInfo
0189: GetTimeZoneInformation
0201: MulDiv
0187: GetTimeFormatA
010D: GetDateFormatA
0099: FileTimeToSystemTime
0098: FileTimeToLocalFileTime
0120: GetFileAttributesA
01C8: InterlockedDecrement
----------------------------------------
----------------------------------------
IMAGE_IMPORT_DESCRIPTOR - SIZE: 20
Characteristics 0x000924DC
TimeDateStamp 0x00000000
ForwarderChain 0x00000000
Name 0x000931DC
FirstThunk 0x0009039C
----------------------------------------
Imported from USER32.dll
Hint Function
-----------------------
01F6: RegisterClassA
00DF: GetActiveWindow
0196: IsWindowVisible
026F: ShowWindow
0105: GetDlgItem
010A: GetFocus
0138: GetParent
0213: SendDlgItemMessageA
00B9: EnableWindow
01D7: OffsetRect
015A: GetWindowLongA
017E: InvalidateRect
00B1: DrawTextA
01A2: LoadIconA
0095: DialogBoxParamA
0160: GetWindowRect
022A: SetCursor
0263: SetWindowTextA
01EE: PtInRect
0220: SetActiveWindow
0234: SetForegroundWindow
00D2: EnumWindows
0166: GetWindowThreadProcessId
0190: IsIconic
019A: LoadAcceleratorsA
0287: TranslateMessage
0149: GetSystemMetrics
005A: CreateWindowExA
0296: UpdateWindow
0284: TranslateAcceleratorA
022C: SetCursorPos
00D7: FindWindowA
0233: SetFocus
0276: SystemParametersInfoA
000C: BeginPaint
00BD: EndPaint
0218: SendMessageA
0221: SetCapture
0206: ReleaseCapture
0086: DefWindowProcA
00FF: GetCursorPos
020E: ScreenToClient
0102: GetDesktopWindow
00BB: EndDialog
026B: ShowCursor
00F3: GetClientRect
0146: GetSysColor
019E: LoadCursorA
01CF: MsgWaitForMultipleObjects
0097: DispatchMessageA
0199: KillTimer
0257: SetTimer
02B3: wsprintfA
0260: SetWindowPos
0100: GetDC
0207: ReleaseDC
01E3: PostMessageA
0230: SetDlgItemTextA
010B: GetForegroundWindow
01E1: PeekMessageA
0156: GetWindow
00F0: GetClassNameA
025D: SetWindowLongA
01C3: MessageBoxA
01AF: LoadStringA
008B: DestroyAcceleratorTable
----------------------------------------
----------------------------------------
IMAGE_IMPORT_DESCRIPTOR - SIZE: 20
Characteristics 0x00092148
TimeDateStamp 0x00000000
ForwarderChain 0x00000000
Name 0x00093328
FirstThunk 0x00090008
----------------------------------------
Imported from GDI32.dll
Hint Function
-----------------------
00A2: ExtTextOutA
0037: CreateFontA
0191: MoveToEx
020C: TextOutA
01F8: SetTextAlign
01D4: SetBkColor
01FA: SetTextColor
0172: GetTextExtentExPointA
012D: GetDeviceCaps
017E: GetTextMetricsA
0054: DeleteObject
0157: GetObjectA
0038: CreateFontIndirectA
002B: CreateCompatibleDC
01CE: SelectObject
0176: GetTextExtentPoint32A
0051: DeleteDC
015C: GetPaletteEntries
0167: GetStockObject
----------------------------------------
----------------------------------------
IMAGE_IMPORT_DESCRIPTOR - SIZE: 20
Characteristics 0x00092140
TimeDateStamp 0x00000000
ForwarderChain 0x00000000
Name 0x00093342
FirstThunk 0x00090000
----------------------------------------
Imported from ADVAPI32.dll
Hint Function
-----------------------
00F3: GetUserNameA
----------------------------------------
----------------------------------------
IMAGE_IMPORT_DESCRIPTOR - SIZE: 20
Characteristics 0x00092348
TimeDateStamp 0x00000000
ForwarderChain 0x00000000
Name 0x000933A8
FirstThunk 0x00090208
----------------------------------------
Imported from SHELL32.dll
Hint Function
-----------------------
0063: SHGetPathFromIDListA
008C: ShellExecuteA
0027: FindExecutableA
0066: SHGetSpecialFolderLocation
----------------------------------------
----------------------------------------
IMAGE_IMPORT_DESCRIPTOR - SIZE: 20
Characteristics 0x000925F8
TimeDateStamp 0x00000000
ForwarderChain 0x00000000
Name 0x000933B4
FirstThunk 0x000904B8
----------------------------------------
Imported from WSOCK32.dll
Hint Function
-----------------------
Ord0015
Ord0011
Ord0073
Ord0017
Ord0014
Ord000C
Ord0009
Ord0002
Ord0006
Ord0003
Ord0074
----------------------------------------
----------------------------------------
IMAGE_IMPORT_DESCRIPTOR - SIZE: 20
Characteristics 0x000925E8
TimeDateStamp 0x00000000
ForwarderChain 0x00000000
Name 0x00093402
FirstThunk 0x000904A8
----------------------------------------
Imported from VERSION.dll
Hint Function
-----------------------
0001: GetFileVersionInfoSizeA
0000: GetFileVersionInfoA
000A: VerQueryValueA
----------------------------------------
LTW - light water
DKW - dark water
LTM - light mud(coast)
DKM - dark mud
LTG - light grass
DKG - dark grass
TRE - trees
ROC - rocks
HWL - human wall
OWL - orc wall
i.e.
0x0050 LTG variant 0
0x0051 LTG variant 1
0x0055 LTG variant 5
etc.
LTG/DKG - 0-2 Plain Solid
LTG/DKG - 4-9 Filler Solid
LTM/DKM - 0-3 Plain Solid
LTM/DKM - 4-B Filler Solid
i.e. 0x0057 = LTG 4th filler tile (the one with the big rock)0x001v - LTW
0x002v - DKW
0x003v - LTM
0x004v - DKM
0x005v - LTG
0x006v - DKG
0x007v - TRE
0x008v - ROC
0x009v - OWL (Single)
0x00Av - HWL (Single)
0x00Bv - OWL (central)
0x00Cv - HWL (central)
Where v designates the graphics variant.
v=0-1 Full
v=2 Damaged
v=3 Full
v=4 Destroyed
v=5-F Full
Value (0) (1)
0x01Lv - LTW/DKW
0x02Lv - LTM/LTW
0x03Lv - LTM/DKM
0x04Lv - LTM/ROC
0x05Lv - LTG/LTM
0x06Lv - LTG/DKG
0x07Lv - LTG/TRE
Where v designates the graphics variant.
Where L designates the layout.
bit0 - bit1
| |
bit2 - bit3
TG
TT
(all trees except grass in the top right)10
11
0x08Lv - HWL Joined
0x09Lv - OWL Joined
BIT 2
3 # 1
0
###
#
= 0x09A0Almost ready for an alpha test of the basic editor. Have the terrain / terraforming / unit placement working reasonably well. Everything works at any zoom, so you can even view a large map full screen and still edit it. Can place half terrain tiles - like thin rivers etc. :fro:I'll test the shit out of it. Spawn the beta ;)
Havn't done a mini-map yet and it really doesn't need one - you just zoom in/out with the mouse wheel at any time. Will probably add one at some point I guess but it's not at the top of the list.
Still have a half-page TO DO list of things to tweak. Hopefully I'll get those done tomorrow then I'll need some testers (@easycompany and @tupac spring to mind :) ).
Still haven't done any unit editing - starting conditions ... etc. etc. although all that + all the tricks can be added once the basic GUI is nice and tight.... At the moment it does pretty much everything my old editor can't do and none of the things that it can lol.
:critter:
if u didt get that szawg i dont know how else to tell yaMaybe im blind, but where did u change missing objective build 6 farms not 4??
ALLIED COLORS ON MINI-MAP
This one was another idea from Nedro, it makes all allies blue and all enemies red on the mini-map.
You can toggle it on/off by pushing F2.
([url]http://forum.war2.ru/index.php?action=dlattach;topic=2703.0;attach=2177[/url])
I like that!!!
@Lambchops May we have the sources of that nice little program of yours? (The PUDPIC program) ^-^
// This stuff in .h file <-----
extern "C" {
typedef struct pudsect {
DWORD Reserved;
DWORD name;
DWORD size;
LPVOID data;
}PUDSECT;
}
extern "C" {
typedef struct hmibmp {
BITMAPFILEHEADER* pFile;
BITMAPINFOHEADER* pInfo;
RGBQUAD* pPal;
BYTE* pBits;
int width;
int height;
int bpp;
int linew;
int usage;
int size;
}HMIBMP;
}
// LambRES.dll
extern "C" typedef CHAR* (__stdcall *rfngetname )(int utype);
extern "C" typedef LPVOID (__stdcall *rfntileset )(int ntileset);
extern "C" typedef LPVOID (__stdcall *rfngetpal )(int npalette);
extern "C" typedef LPVOID (__stdcall *rfngetgrp )();
//PUDfile.inc
extern "C" typedef LPVOID (__stdcall *pfnpudload )(CHAR* path);
extern "C" typedef int (__stdcall *pfnpudsave )(LPVOID hpud,CHAR* path);
//PUDpud.inc
extern "C" typedef int (__stdcall *pfnsectcnt )(LPVOID hpud);
extern "C" typedef void (__stdcall *pfndestroy )(LPVOID hpud);
extern "C" typedef LPVOID (__stdcall *pfndelsect )(LPVOID hpud,LPVOID hsect);
extern "C" typedef PUDSECT*(__stdcall *pfnfindsect)(LPVOID hpud,DWORD sectname);
extern "C" typedef int (__stdcall *pfnupdsect )(LPVOID hpud,LPVOID hsect,LPVOID lpnew,int nbytes);
extern "C" typedef PUDSECT*(__stdcall *pfngetsect )(LPVOID hpud,int nsect);
extern "C" typedef int (__stdcall *pfnsectndx )(LPVOID hpud,DWORD sectname);
extern "C" typedef LPVOID (__stdcall *pfnsectset )(LPVOID hpud,LPVOID hsect,int nsect);
extern "C" typedef BOOL (__stdcall *pfnsectcre )(LPVOID hpud,DWORD sectname,LPVOID lpnew,int nbytes);
extern "C" typedef LPVOID (__stdcall *pfnrealloc )(PUDSECT* hSect,int nbytes);
//PUDunit.inc
extern "C" typedef int (__stdcall *pfnunitsize)(int utype);
extern "C" typedef int (__stdcall *pfnuniticof)(int utype);
extern "C" typedef int (__stdcall *pfnlistget )(int list,int ndx);
extern "C" typedef int (__stdcall *pfnlistnext)(int list,int utype);
extern "C" typedef int (__stdcall *pfnlistprev)(int list,int utype);
extern "C" typedef LPVOID (__stdcall *pfnlistname)(int list);
//PUDtile.inc
extern "C" typedef void (__stdcall *pfnrndrmap )(LPVOID hbmp,LPVOID mtxm,int mapw);
extern "C" typedef void (__stdcall *pfnrndrtile)(LPVOID hbmp,int tile,int x,int y);
extern "C" typedef LPVOID (__stdcall *pfngettile )(int tile);
extern "C" typedef void (__stdcall *pfntileset )(LPVOID tileset);
extern "C" typedef void (__stdcall *pfnblack )(HDC dc,int x,int y,int w,int h);
//hmibmp.inc
extern "C" typedef HMIBMP* (__stdcall *pfnmakebmp )(int w,int h,int bpp);
extern "C" typedef void (__stdcall *pfnfreebmp )(HMIBMP* bmp);
extern "C" typedef int (__stdcall *pfnzerobmp )(HMIBMP* bmp);
extern "C" typedef void (__stdcall *pfnsavebmp )(CHAR* path,HMIBMP* bmp);
extern "C" typedef void (__stdcall *pfnsavejpg )(CHAR* path,HMIBMP* bmp,int quality);
extern "C" typedef void (__stdcall *pfnperfbmp )(HMIBMP* bmp);
extern "C" typedef void (__stdcall *pfncopyimg )(HMIBMP* src,int scrx,int srcy,int srcw,int scrh,HMIBMP* dst,int dstx,int dsty,int transp);
extern "C" typedef int (__stdcall *pfncopyfull)(HMIBMP* dstbmp,HMIBMP* srcbmp,int transp);
extern "C" typedef void (__stdcall *pfndispimg )(HDC destDC,int x,int y,int w,int h,HMIBMP* bmp,int dx,int dy,int dw,int dh);
extern "C" typedef void (__stdcall *pfnsetpal )(HMIBMP* bmp,LPVOID palette);
extern "C" typedef void (__stdcall *pfndrawrect)(HMIBMP* bmp,int x,int y,int w,int h,int color);
extern "C" typedef HMIBMP* (__stdcall *pfnsizebmp )(HMIBMP* bmp,int w,int h);
//PUDgrp.inc
extern "C" typedef LPVOID (__stdcall *pfngrpinit )(LPVOID grplubase);
extern "C" typedef void (__stdcall *pfndrawgrp )(int grp,int nframe,LPVOID daddr,int dwidth,int owner,int centre,int mirror);
extern "C" typedef void (__stdcall *pfndrawbtn )(LPVOID bmp, int xpos, int ypos, int icon, int state);
extern rfngetname RESgetName;
extern rfntileset RESgetTileset;
extern rfngetpal RESgetPalette;
extern rfngetgrp RESgetGrp;
extern pfnpudload PUDload;
extern pfnpudsave PUDsave;
extern pfnsectcnt PUDsection_count;
extern pfndestroy PUDdestroy;
extern pfndelsect PUDdelete_section;
extern pfnfindsect PUDfind_section;
extern pfnupdsect PUDupdate_section;
extern pfngetsect PUDget_section;
extern pfnsectndx PUDsection_index;
extern pfnsectset PUDsection_set_index;
extern pfnsectcre PUDcreate_section;
extern pfnrealloc PUDsection_realloc;
extern pfnunitsize PUDunitSize;
extern pfnuniticof PUDunitIconFrame;
extern pfnlistget PUDlistGet;
extern pfnlistnext PUDlistNext;
extern pfnlistprev PUDlistPrev;
extern pfnlistname PUDlistName;
extern pfnrndrmap PUDrenderMap;
extern pfnrndrtile PUDrenderTile;
extern pfngettile PUDgetTile;
extern pfntileset PUDtileset;
extern pfnblack PUDblack;
extern pfnmakebmp make_bitmap;
extern pfnfreebmp free_bitmap;
extern pfnzerobmp zero_bitmap;
extern pfnsavebmp save_bitmap;
extern pfnsavejpg save_jpeg;
extern pfnperfbmp perforate_bitmap;
extern pfncopyimg copy_image;
extern pfncopyfull copy_full_image;
extern pfndispimg display_image;
extern pfnsetpal set_palette;
extern pfndrawrect draw_rect;
extern pfnsizebmp size_bitmap;
extern pfngrpinit GRPinit;
extern pfndrawgrp GRPdraw;
extern pfndrawbtn GRPdrawButton;
///////////////////////////////////////////////////////////////////////////////
// This stuff in .cpp file <-------
HMODULE hResDll = LoadLibraryA("LambRES");
HMODULE hLambDll = LoadLibraryA("LambWC2");
rfngetpal RESgetPalette = (rfngetpal )GetProcAddress(hResDll , "RESgetPalette" );
rfngetgrp RESgetGrp = (rfngetgrp )GetProcAddress(hResDll , "RESgetGrp" );
rfngetname RESgetName = (rfngetname )GetProcAddress(hResDll , "RESgetName" );
rfntileset RESgetTileset = (rfntileset )GetProcAddress(hResDll , "RESgetTileset" );
pfnpudload PUDload = (pfnpudload )GetProcAddress(hLambDll, "PUDload" );
pfnpudsave PUDsave = (pfnpudsave )GetProcAddress(hLambDll, "PUDsave" );
pfnsectcnt PUDsection_count = (pfnsectcnt )GetProcAddress(hLambDll, "PUDsection_count" );
pfndestroy PUDdestroy = (pfndestroy )GetProcAddress(hLambDll, "PUDdestroy" );
pfndelsect PUDdelete_section = (pfndelsect )GetProcAddress(hLambDll, "PUDdelete_section" );
pfnfindsect PUDfind_section = (pfnfindsect)GetProcAddress(hLambDll, "PUDfind_section" );
pfnupdsect PUDupdate_section = (pfnupdsect )GetProcAddress(hLambDll, "PUDupdate_section" );
pfngetsect PUDget_section = (pfngetsect )GetProcAddress(hLambDll, "PUDget_section" );
pfnsectndx PUDsection_index = (pfnsectndx )GetProcAddress(hLambDll, "PUDsection_index" );
pfnsectset PUDsection_set_index= (pfnsectset )GetProcAddress(hLambDll, "PUDsection_set_index");
pfnsectcre PUDcreate_section = (pfnsectcre )GetProcAddress(hLambDll, "PUDcreate_section" );
pfnrealloc PUDsection_realloc = (pfnrealloc )GetProcAddress(hLambDll, "PUDsection_realloc" );
pfnunitsize PUDunitSize = (pfnunitsize)GetProcAddress(hLambDll, "PUDunitSize" );
pfnuniticof PUDunitIconFrame = (pfnuniticof)GetProcAddress(hLambDll, "PUDunitIconFrame" );
pfnlistget PUDlistGet = (pfnlistget )GetProcAddress(hLambDll, "PUDlistGet" );
pfnlistnext PUDlistNext = (pfnlistnext)GetProcAddress(hLambDll, "PUDlistNext" );
pfnlistprev PUDlistPrev = (pfnlistprev)GetProcAddress(hLambDll, "PUDlistPrev" );
pfnlistname PUDlistName = (pfnlistname)GetProcAddress(hLambDll, "PUDlistName" );
pfnrndrmap PUDrenderMap = (pfnrndrmap )GetProcAddress(hLambDll, "PUDrenderMap" );
pfnrndrtile PUDrenderTile = (pfnrndrtile)GetProcAddress(hLambDll, "PUDrenderTile" );
pfngettile PUDgetTile = (pfngettile )GetProcAddress(hLambDll, "PUDgetTile" );
pfntileset PUDtileset = (pfntileset )GetProcAddress(hLambDll, "PUDtileset" );
pfnblack PUDblack = (pfnblack )GetProcAddress(hLambDll, "PUDblack" );
pfnmakebmp make_bitmap = (pfnmakebmp )GetProcAddress(hLambDll, "make_bitmap" );
pfnfreebmp free_bitmap = (pfnfreebmp )GetProcAddress(hLambDll, "free_bitmap" );
pfnzerobmp zero_bitmap = (pfnzerobmp )GetProcAddress(hLambDll, "zero_bitmap" );
pfnsavebmp save_bitmap = (pfnsavebmp )GetProcAddress(hLambDll, "save_bitmap" );
pfnsavejpg save_jpeg = (pfnsavejpg )GetProcAddress(hLambDll, "save_jpeg" );
pfnsizebmp size_bitmap = (pfnsizebmp )GetProcAddress(hLambDll, "size_bitmap" );
pfnperfbmp perforate_bitmap = (pfnperfbmp )GetProcAddress(hLambDll, "perforate_bitmap" );
pfncopyimg copy_image = (pfncopyimg )GetProcAddress(hLambDll, "copy_image" );
pfncopyfull copy_full_image = (pfncopyfull)GetProcAddress(hLambDll, "copy_full_image" );
pfndispimg display_image = (pfndispimg )GetProcAddress(hLambDll, "display_td_image" );
pfnsetpal set_palette = (pfnsetpal )GetProcAddress(hLambDll, "set_palette" );
pfndrawrect draw_rect = (pfndrawrect)GetProcAddress(hLambDll, "draw_rect" );
pfngrpinit GRPinit = (pfngrpinit )GetProcAddress(hLambDll, "GRPinit" );
pfndrawgrp GRPdraw = (pfndrawgrp )GetProcAddress(hLambDll, "GRPdraw" );
pfndrawbtn GRPdrawButton = (pfndrawbtn )GetProcAddress(hLambDll, "GRPdrawButton" );
PUDtileset(RESgetTileset(0));
GRPinit(RESgetGrp());
pFile pointer to the BITMAPFILEHEADER struct
pInfo pointer to the BITMAPINFOHEADER struct
pPal pointer to the palette (if the bitmap has one)
pBits pointer to the pixmap (actual pixel data - depends on the format)
width duh
height duh
bpp bits per pixel (this will be 8 for most WC2 things)
linew internal size in bytes for one line of pixels
usage (pixel color values or palette entries)
size total size of all structures
HMIBMP* MyBmp = make_bitmap(300,200,8);
free_bitmap(MyBmp);
LPVOID MyPud = PUDload("c:\\someMap.pud");
BYTE* sectionData(LPVOID hPud, DWORD sname){
PUDSECT* sptr = PUDfind_section(hPud,sname);
if (sptr!=NULL) return sptr->data;
return NULL;
}
#define sTYPE 0x45505954 // "TYPE"
#define sVER_ 0x20524556 // "VER "
#define sDESC 0x43534544 // "DESC"
#define sOWNR 0x524E574F // "OWNR"
#define sERA_ 0x20415245 // "ERA "
#define sERAX 0x54415245 // "ERAX"
#define sDIM_ 0x204D4944 // "DIM "
#define sUDTA 0x41544455 // "UDTA"
#define sUNIT 0x54494E55 // "UNIT"
#define sUGRD 0x44524755 // "UGRD"
#define sSIDE 0x45444953 // "SIDE"
#define sSGLD 0x444C4753 // "SGLD"
#define sSLBR 0x52424C53 // "SLBR"
#define sSOIL 0x4C494F53 // "SOIL"
#define sAIPL 0x4C504941 // "AIPL"
#define sMTXM 0x4D58544D // "MTXM"
#define sSQM_ 0x204D5153 // "SQM "
#define sOILM 0x4D4C494F // "OILM"
#define sREGM 0x4D474552 // "REGM"
#define sSIGN 0x4E474953 // "SIGN"
#define sALOW 0x574F4C41 // "ALOW"
int getPudDim(LPVOID hpud){
WORD* pdim = (WORD*) sectionData(hpud,sDIM_)
if (pdim) return (int) *pdim;
return 0;
}
PUDrenderTile(MyBmp, tileValue , int x, int y);
PUDrenderMap(MyBmp, MTXM_section, size);
#define FOREST 0
#define WINTER 1
#define WASTELAND 2
#define SWAMP 3
PUDtileset(RESgetTileset( WINTER ));
set_palette(MyBmp , RESgetPalette( WINTER ));
// # UNTESTED # - probably has errors/typos
#include <windows.h>
//#include HEADER FILE WITH IMPORT DEFS FROM PREVIOUS POST AND CONSTANT DEFS (ABOVE)
CHAR* pudpath = "myMap.pud";
CHAR* bmppath = "this.bmp";
// load the pud file
LPVOID hPud = PUDload(pudpath);
BYTE* sectionData(LPVOID hpud, DWORD sname){
PUDSECT* sptr = PUDfind_section(hpud,sname);
if (sptr!=NULL) return (BYTE*)sptr->data;
return NULL;
}
int getPudSize(LPVOID hpud){
WORD* pdim = (WORD*) sectionData(hpud,sDIM_);
if(pdim) return (int) *pdim;
return 0;
}
int getTerrainType(LPVOID hpud){
WORD* pter = (WORD*) sectionData(hpud,sERA_);
if(pter) return (int) *pter;
return 0;
}
// get some info from the pud
int mapsize = getPudSize(hPud);
int terrain = getTerrainType(hPud);
// make a bitmap in memory (tiles are 32x32 pixels)
HMIBMP* hbm = make_bitmap(mapsize*32,mapsize*32,8);
// use the tiles for the map terrain type
PUDtileset(RESgetTileset(terrain));
// don't forget this if you are using GRPs, only needs to be done once to initialize
// can't remember if it needs to be done for only the terrain, but it cant hurt lol
GRPinit(RESgetGrp());
//paste all the tile graphics for the pud onto the bitmap
PUDrenderMap( hbm, sectionData(hpud,sMTXM) , mapsize);
// ensure the bmp file has the correct palette for the terrain type
set_palette(hbm , RESgetPalette( terrain ));
// save the bitmap to a file
save_bitmap(bmppath,hbm);
// dispose of the bitmap
free_bitmap(hbm);
// dispose of the pud structure
PUDdestroy(hPud);
display_image( dc, windowX, windowY, displayWidth, displayHeight, hbm, bmX, bmY, bmW, bmH );
display_image(dc,0,0,0,0,hbm,0,0,0,0);
will just display the bitmap on the window without any resizing.The reason is, I checked your archive and it is flagged as malicious by most common anti viruses,
The virus detection matters because even if we know it is perfectly safe if we want to put it in the downloads section of the site for everyone to find easily, and google runs a basic automated test like they always do on hosted files, they will flag the whole war2.ru site as malicious, as it happened before.
Are these sources somewhere on Github? That would be much handier to read/propose changes or additions .... / snip /.... Do you think it could be a good idea? :-)
nless you really want to use these as a way to get noticed by employers or because you want that to be part of your resume or portfolio. <= which also could be quite a good idea but that is indeed more work
#include <windows.h>
#ifndef _LAMB_
#define _LAMB_
#define sTYPE 0x45505954 // "TYPE"
#define sVER_ 0x20524556 // "VER "
#define sDESC 0x43534544 // "DESC"
#define sOWNR 0x524E574F // "OWNR"
#define sERA_ 0x20415245 // "ERA "
#define sERAX 0x54415245 // "ERAX"
#define sDIM_ 0x204D4944 // "DIM "
#define sUDTA 0x41544455 // "UDTA"
#define sUNIT 0x54494E55 // "UNIT"
#define sUGRD 0x44524755 // "UGRD"
#define sSIDE 0x45444953 // "SIDE"
#define sSGLD 0x444C4753 // "SGLD"
#define sSLBR 0x52424C53 // "SLBR"
#define sSOIL 0x4C494F53 // "SOIL"
#define sAIPL 0x4C504941 // "AIPL"
#define sMTXM 0x4D58544D // "MTXM"
#define sSQM_ 0x204D5153 // "SQM "
#define sOILM 0x4D4C494F // "OILM"
#define sREGM 0x4D474552 // "REGM"
#define sSIGN 0x4E474953 // "SIGN"
#define sALOW 0x574F4C41 // "ALOW"
#define FOREST 0
#define WINTER 1
#define WASTELAND 2
#define SWAMP 3
#define TILEW 32
#define TILEW2 16
extern "C" {
typedef struct pudsect {
DWORD Reserved;
DWORD name;
DWORD size;
LPVOID data;
}PUDSECT;
}
extern "C" {
typedef struct hmibmp {
BITMAPFILEHEADER* pFile;
BITMAPINFOHEADER* pInfo;
RGBQUAD* pPal;
BYTE* pBits;
int width;
int height;
int bpp;
int linew;
int usage;
int size;
}HMIBMP;
}
extern "C" {
typedef struct pudunit{
WORD x;
WORD y;
BYTE type;
BYTE owner;
WORD ai; // 0-passive 1-active or (gold or oil)/2500
}PUDUNIT;
}
// LambRES.dll
extern "C" typedef CHAR* (__stdcall *rfngetname )(int utype);
extern "C" typedef LPVOID (__stdcall *rfntileset )(int ntileset);
extern "C" typedef LPVOID (__stdcall *rfngetpal )(int npalette);
extern "C" typedef LPVOID (__stdcall *rfngetgrp )();
//PUDfile.inc
extern "C" typedef LPVOID (__stdcall *pfnpudload )(CHAR* path);
extern "C" typedef int (__stdcall *pfnpudsave )(LPVOID hpud,CHAR* path);
//PUDpud.inc
extern "C" typedef int (__stdcall *pfnsectcnt )(LPVOID hpud);
extern "C" typedef void (__stdcall *pfndestroy )(LPVOID hpud);
extern "C" typedef LPVOID (__stdcall *pfndelsect )(LPVOID hpud,LPVOID hsect);
extern "C" typedef PUDSECT*(__stdcall *pfnfindsect)(LPVOID hpud,DWORD sectname);
extern "C" typedef int (__stdcall *pfnupdsect )(LPVOID hpud,LPVOID hsect,LPVOID lpnew,int nbytes);
extern "C" typedef PUDSECT*(__stdcall *pfngetsect )(LPVOID hpud,int nsect);
extern "C" typedef int (__stdcall *pfnsectndx )(LPVOID hpud,DWORD sectname);
extern "C" typedef LPVOID (__stdcall *pfnsectset )(LPVOID hpud,LPVOID hsect,int nsect);
extern "C" typedef BOOL (__stdcall *pfnsectcre )(LPVOID hpud,DWORD sectname,LPVOID lpnew,int nbytes);
extern "C" typedef LPVOID (__stdcall *pfnrealloc )(PUDSECT* hSect,int nbytes);
//PUDunit.inc
extern "C" typedef int (__stdcall *pfnunitsize)(int utype);
extern "C" typedef int (__stdcall *pfnuniticof)(int utype);
extern "C" typedef int (__stdcall *pfnlistget )(int list,int ndx);
extern "C" typedef int (__stdcall *pfnlistnext)(int list,int utype);
extern "C" typedef int (__stdcall *pfnlistprev)(int list,int utype);
extern "C" typedef LPVOID (__stdcall *pfnlistname)(int list);
//PUDtile.inc
extern "C" typedef void (__stdcall *pfnrndrmap )(LPVOID hbmp,LPVOID mtxm,int mapw);
extern "C" typedef void (__stdcall *pfnrndrtile)(LPVOID hbmp,int tile,int x,int y);
extern "C" typedef LPVOID (__stdcall *pfngettile )(int tile);
extern "C" typedef void (__stdcall *pfntileset )(LPVOID tileset);
extern "C" typedef void (__stdcall *pfnblack )(HDC dc,int x,int y,int w,int h);
//hmibmp.inc
extern "C" typedef HMIBMP* (__stdcall *pfnmakebmp )(int w,int h,int bpp);
extern "C" typedef void (__stdcall *pfnfreebmp )(HMIBMP* bmp);
extern "C" typedef int (__stdcall *pfnzerobmp )(HMIBMP* bmp);
extern "C" typedef void (__stdcall *pfnsavebmp )(CHAR* path,HMIBMP* bmp);
extern "C" typedef void (__stdcall *pfnsavejpg )(CHAR* path,HMIBMP* bmp,int quality);
extern "C" typedef void (__stdcall *pfnperfbmp )(HMIBMP* bmp);
extern "C" typedef void (__stdcall *pfncopyimg )(HMIBMP* src,int scrx,int srcy,int srcw,int scrh,HMIBMP* dst,int dstx,int dsty,int transp);
extern "C" typedef int (__stdcall *pfncopyfull)(HMIBMP* dstbmp,HMIBMP* srcbmp,int transp);
extern "C" typedef void (__stdcall *pfndispimg )(HDC destDC,int x,int y,int w,int h,HMIBMP* bmp,int dx,int dy,int dw,int dh);
extern "C" typedef void (__stdcall *pfnsetpal )(HMIBMP* bmp,LPVOID palette);
extern "C" typedef void (__stdcall *pfndrawrect)(HMIBMP* bmp,int x,int y,int w,int h,int color);
extern "C" typedef HMIBMP* (__stdcall *pfnsizebmp )(HMIBMP* bmp,int w,int h);
//PUDgrp.inc
extern "C" typedef LPVOID (__stdcall *pfngrpinit )(LPVOID grplubase);
extern "C" typedef void (__stdcall *pfndrawgrp )(int grp,int nframe,LPVOID daddr,int dwidth,int owner,int centre,int mirror);
extern "C" typedef void (__stdcall *pfndrawbtn )(LPVOID bmp, int xpos, int ypos, int icon, int state);
extern rfngetname RESgetName;
extern rfntileset RESgetTileset;
extern rfngetpal RESgetPalette;
extern rfngetgrp RESgetGrp;
extern pfnpudload PUDload;
extern pfnpudsave PUDsave;
extern pfnsectcnt PUDsection_count;
extern pfndestroy PUDdestroy;
extern pfndelsect PUDdelete_section;
extern pfnfindsect PUDfind_section;
extern pfnupdsect PUDupdate_section;
extern pfngetsect PUDget_section;
extern pfnsectndx PUDsection_index;
extern pfnsectset PUDsection_set_index;
extern pfnsectcre PUDcreate_section;
extern pfnrealloc PUDsection_realloc;
extern pfnunitsize PUDunitSize;
extern pfnuniticof PUDunitIconFrame;
extern pfnlistget PUDlistGet;
extern pfnlistnext PUDlistNext;
extern pfnlistprev PUDlistPrev;
extern pfnlistname PUDlistName;
extern pfnrndrmap PUDrenderMap;
extern pfnrndrtile PUDrenderTile;
extern pfngettile PUDgetTile;
extern pfntileset PUDtileset;
extern pfnblack PUDblack;
extern pfnmakebmp make_bitmap;
extern pfnfreebmp free_bitmap;
extern pfnzerobmp zero_bitmap;
extern pfnsavebmp save_bitmap;
extern pfnsavejpg save_jpeg;
extern pfnperfbmp perforate_bitmap;
extern pfncopyimg copy_image;
extern pfncopyfull copy_full_image;
extern pfndispimg display_image;
extern pfnsetpal set_palette;
extern pfndrawrect draw_rect;
extern pfnsizebmp size_bitmap;
extern pfngrpinit GRPinit;
extern pfndrawgrp GRPdraw;
extern pfndrawbtn GRPdrawButton;
#endif
#include <windows.h>
#include <lamb.h>
HMODULE hResDll = LoadLibraryA("LambRES");
HMODULE hLambDll = LoadLibraryA("LambWC2");
rfngetpal RESgetPalette = (rfngetpal )GetProcAddress(hResDll , "RESgetPalette" );
rfngetgrp RESgetGrp = (rfngetgrp )GetProcAddress(hResDll , "RESgetGrp" );
rfngetname RESgetName = (rfngetname )GetProcAddress(hResDll , "RESgetName" );
rfntileset RESgetTileset = (rfntileset )GetProcAddress(hResDll , "RESgetTileset" );
pfnpudload PUDload = (pfnpudload )GetProcAddress(hLambDll, "PUDload" );
pfnpudsave PUDsave = (pfnpudsave )GetProcAddress(hLambDll, "PUDsave" );
pfnsectcnt PUDsection_count = (pfnsectcnt )GetProcAddress(hLambDll, "PUDsection_count" );
pfndestroy PUDdestroy = (pfndestroy )GetProcAddress(hLambDll, "PUDdestroy" );
pfndelsect PUDdelete_section = (pfndelsect )GetProcAddress(hLambDll, "PUDdelete_section" );
pfnfindsect PUDfind_section = (pfnfindsect)GetProcAddress(hLambDll, "PUDfind_section" );
pfnupdsect PUDupdate_section = (pfnupdsect )GetProcAddress(hLambDll, "PUDupdate_section" );
pfngetsect PUDget_section = (pfngetsect )GetProcAddress(hLambDll, "PUDget_section" );
pfnsectndx PUDsection_index = (pfnsectndx )GetProcAddress(hLambDll, "PUDsection_index" );
pfnsectset PUDsection_set_index= (pfnsectset )GetProcAddress(hLambDll, "PUDsection_set_index");
pfnsectcre PUDcreate_section = (pfnsectcre )GetProcAddress(hLambDll, "PUDcreate_section" );
pfnrealloc PUDsection_realloc = (pfnrealloc )GetProcAddress(hLambDll, "PUDsection_realloc" );
pfnunitsize PUDunitSize = (pfnunitsize)GetProcAddress(hLambDll, "PUDunitSize" );
pfnuniticof PUDunitIconFrame = (pfnuniticof)GetProcAddress(hLambDll, "PUDunitIconFrame" );
pfnlistget PUDlistGet = (pfnlistget )GetProcAddress(hLambDll, "PUDlistGet" );
pfnlistnext PUDlistNext = (pfnlistnext)GetProcAddress(hLambDll, "PUDlistNext" );
pfnlistprev PUDlistPrev = (pfnlistprev)GetProcAddress(hLambDll, "PUDlistPrev" );
pfnlistname PUDlistName = (pfnlistname)GetProcAddress(hLambDll, "PUDlistName" );
pfnrndrmap PUDrenderMap = (pfnrndrmap )GetProcAddress(hLambDll, "PUDrenderMap" );
pfnrndrtile PUDrenderTile = (pfnrndrtile)GetProcAddress(hLambDll, "PUDrenderTile" );
pfngettile PUDgetTile = (pfngettile )GetProcAddress(hLambDll, "PUDgetTile" );
pfntileset PUDtileset = (pfntileset )GetProcAddress(hLambDll, "PUDtileset" );
pfnblack PUDblack = (pfnblack )GetProcAddress(hLambDll, "PUDblack" );
pfnmakebmp make_bitmap = (pfnmakebmp )GetProcAddress(hLambDll, "make_bitmap" );
pfnfreebmp free_bitmap = (pfnfreebmp )GetProcAddress(hLambDll, "free_bitmap" );
pfnzerobmp zero_bitmap = (pfnzerobmp )GetProcAddress(hLambDll, "zero_bitmap" );
pfnsavebmp save_bitmap = (pfnsavebmp )GetProcAddress(hLambDll, "save_bitmap" );
pfnsavejpg save_jpeg = (pfnsavejpg )GetProcAddress(hLambDll, "save_jpeg" );
pfnsizebmp size_bitmap = (pfnsizebmp )GetProcAddress(hLambDll, "size_bitmap" );
pfnperfbmp perforate_bitmap = (pfnperfbmp )GetProcAddress(hLambDll, "perforate_bitmap" );
pfncopyimg copy_image = (pfncopyimg )GetProcAddress(hLambDll, "copy_image" );
pfncopyfull copy_full_image = (pfncopyfull)GetProcAddress(hLambDll, "copy_full_image" );
pfndispimg display_image = (pfndispimg )GetProcAddress(hLambDll, "display_td_image" );
pfnsetpal set_palette = (pfnsetpal )GetProcAddress(hLambDll, "set_palette" );
pfndrawrect draw_rect = (pfndrawrect)GetProcAddress(hLambDll, "draw_rect" );
pfngrpinit GRPinit = (pfngrpinit )GetProcAddress(hLambDll, "GRPinit" );
pfndrawgrp GRPdraw = (pfndrawgrp )GetProcAddress(hLambDll, "GRPdraw" );
pfndrawbtn GRPdrawButton = (pfndrawbtn )GetProcAddress(hLambDll, "GRPdrawButton" );
CHAR* pudpath = "this.pud";
CHAR* bmppath = "this.bmp";
CHAR* jpgpath = "this.jpg";
BYTE* sectionData(LPVOID hpud, DWORD sname){
PUDSECT* sptr = PUDfind_section(hpud,sname);
if (sptr!=NULL) return (BYTE*)sptr->data;
return NULL;
}
int sectionSize(LPVOID hpud, DWORD sname){
PUDSECT* sptr = PUDfind_section(hpud,sname);
if (sptr!=NULL) return sptr->size;
return 0;
}
int getPudSize(LPVOID hpud){
WORD* pdim = (WORD*) sectionData(hpud,sDIM_);
if(pdim) return (int) *pdim;
return 0;
}
int getTerrainType(LPVOID hpud){
WORD* pter = (WORD*) sectionData(hpud,sERA_);
if(pter) return (int) *pter;
return 0;
}
BOOL isBuilding(int utype){
// is the unit a building?
return utype>=0x3A;
}
void renderUnit(HMIBMP* hbm, PUDUNIT* unit){
// draw a unit grp
int frame = 0;
int x=(unit->x+1)*TILEW;
int y=(unit->y+1)*TILEW;
int centre = 0;
int rev = 0;
if(!isBuilding(unit->type)){
// units need to be centred and offset
centre = 1;
x+=TILEW2;
y+=TILEW2;
// pick a random direction so they dont all face the same way
frame = rand()%5;
rev = rand()%2; // draw reversed?
}
GRPdraw( unit->type, frame, hbm->pBits+x+(y*hbm->linew), hbm->linew, unit->owner, centre, rev );
}
///////// START /////////
// load the pud file
LPVOID hPud = PUDload(pudpath);
// get some info from the pud
int mapsize = getPudSize(hPud);
int terrain = getTerrainType(hPud);
// make a bitmap in memory (tiles are 32x32 pixels)
HMIBMP* hbm = make_bitmap(mapsize*TILEW,mapsize*TILEW,8);
/// TERRAIN ///
// use the tiles for the map terrain type
PUDtileset(RESgetTileset(terrain));
// don't forget this if you are using GRPs, only needs to be done once to initialize
GRPinit(RESgetGrp());
//paste all the tile graphics for the pud onto the bitmap
PUDrenderMap( hbm, sectionData(hPud,sMTXM) , mapsize);
/// UNITS ///
// get a pointer to the "UNIT" section
PUDSECT* units = PUDfind_section(hPud,sUNIT);
if(units){
// make a slightly larger bitmap to paste units on
// --> some units like flyers can be placed in locations where they
// will render off the edge of the map (crash and burn).
//
// so here we make a bitmap with a safety margin around the edge
HMIBMP* hUbm = make_bitmap((mapsize+2)*TILEW,(mapsize+2)*TILEW,8);
// how many units on the pud?
// ( includes mines, start locations etc.)
int nUnits = units->size/sizeof(PUDUNIT);
// draw the unit GRPs on the 'safe' bitmap
PUDUNIT* pUnit = (PUDUNIT*)units->data;
for(int i=0;i<nUnits;i++){
renderUnit(hUbm,pUnit);
pUnit++;
}
// copy the unit bitmap (less the border area) onto the terrain bitmap
copy_image(hUbm,TILEW,TILEW,hbm->width,hbm->height,hbm,0,0,0); // <- last 0 is the transparent index
// pass -1 for none.
// dispose of the unit bitmap
free_bitmap(hUbm);
}
// ensure the bmp file has the correct palette for the terrain type
set_palette(hbm , RESgetPalette( terrain ));
// save the full bitmap to a .bmp file
save_bitmap(bmppath,hbm);
// resize the bitmap then save to a .jpg file
HMIBMP* hJbm = size_bitmap(hbm,1024,1024);
save_jpeg(jpgpath,hJbm,90); // <-- quality 90 looks nice
// dispose of bitmaps
free_bitmap(hbm);
free_bitmap(hJbm);
// dispose of the pud structure
PUDdestroy(hPud);
Nice thanks! ^-^ :thumbsup:
Interesting that they save the transition type value from the marching squares algorithm in the pud directly instead of calculating it once at load time. It means your map editor has to save these calculated values in the pud but it also means you can save a pud files with very weird transitions if you would like to that could look funny. (:
:critter:
u are invited to my xmas party
// Warcraft II font Extractor/Compiler
// Lambchops Feb 2019
#include <windows.h>
#include <shlwapi.h>
#define INVALID_FILE 1
#define INVALID_INPUT 2
#define READ_ERROR 3
#define WRITE_ERROR 4
#define ALLOC_FAIL 5
#define BG_COLOR 0x18
#define MAX_CHAR_SIZE 4108
typedef struct _FontHeader {
DWORD FourCC; // Always "FONT"
BYTE LowIndex; // Index of first letter in file
BYTE HighIndex; // Index of the last letter in file
BYTE MaxWidth; // Maximum width
BYTE MaxHeight; // Maximum height
} FontHeader;
typedef struct _FontLetterRaw {
BYTE Width; // Width of the letter
BYTE Height; // Height of the letter
BYTE XOffset; // X Offset for the topleft corner of the letter.
BYTE YOffset; // Y Offset for the topleft corner of the letter.
} FontLetterRaw;
BYTE clrndx[ ] = {BG_COLOR,0xC8,0xC7,0x4A,0xC0,0x00};
char f_ext[] = "fnt";
char b_ext[] = "bmp";
char szBmpTmpl[] = "_%3.3d.bmp";
char szFntTmpl[] = ".fnt";
char szFont4cc[] = "FONT";
char pathbuf[512];
char szHelpText[] = " Warcraft II Font Extractor/Compiler - Lambchops Feb 2019\r\rDrop a .fnt file to extract.\rDrop one of the extracted .bmp files to compile.\r\r *Make sure you only use the existing colors when editing\r unknown colors will be deleted.";
// --- FILE/PATH --- //
int get_flen(CHAR* path){
HANDLE fn = CreateFile(path,GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,0,0);
int r = GetFileSize(fn,NULL);
CloseHandle(fn);
return r;
}
CHAR* filename(CHAR* lppath){
CHAR* r = lppath+lstrlen(lppath);
while(r>lppath){
if(*r==0x5C)return (r+1);
r--;
}
return lppath;
}
CHAR* get_extension(CHAR* lppath){
CHAR* r = lppath+lstrlen(lppath);
CHAR* def = r;
while(r>lppath){
if(*r==0x2E)return (r+1);
r--;
}
return def;
}
int loadlen;
HANDLE bload(char* path){
// Allocate global memory and read in a file
HANDLE fn = CreateFile(path,GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,0,0);
DWORD nb;
HANDLE fdat;
if(fn!=INVALID_HANDLE_VALUE){
loadlen = GetFileSize(fn,NULL);
// allocate a buffer
fdat = GlobalAlloc(GPTR,loadlen);
// read file into buffer
ReadFile(fn,fdat, loadlen, &nb, NULL);
CloseHandle(fn);
if(nb==loadlen)return fdat;
GlobalFree(fdat);
}
return NULL;
}
// --- BITMAP --- //
int bmp8len = 0x1436;
DWORD bmp8[] = {0x14364D42,0,0x04360000,0x00280000,0x00400000,0x00400000,0x00010000,0x00000008,0x10000000,0,0,0,0,0,0x94FC0000,
0xD0000000,0xFF0000FC,0x00FC0000,0x00FC0000,0x00FC0000,0x00FC0000,0x00FC0000,0x00FC0000,0x28280000,0x00FC00CC,0xFC480000,0xCC2800FC,0xA01000E4,0x740000CC,0x240000B4,0x2C000000,
0x34000000,0x40040014,0x4804000C,0x540C0024,0x5C100028,0x6414002C,0x6C1C003C,0x7828004C,0x8030005C,0x8C3C006C,0x4C000080,0x20540000,0x285C0000,0x2C640000,0x30680000,0x34700000,
0x38740004,0x44780004,0x50800008,0x5C880010,0x487C0018,0x4C80000C,0x4880000C,0x447C000C,0x40780008,0x38740008,0x38740004,0x38740004,0x38740004,0x40780004,0x50840008,0x5C8C0010,
0x6C940018,0x608C0024,0x5888001C,0x50840014,0x20040010,0x2808003C,0x34100048,0x042C0058,0x042C00FC,0x540000FC,0x60040000,0x70340010,0x7C1C003C,0xA038004C,0x04040080,0x10100004,
0x18180010,0x24240018,0x30300024,0x3C3C0030,0x4848003C,0x50500048,0x5C5C0050,0x6868005C,0x74740068,0x7C7C0074,0x8888007C,0x94940088,0xA0A00094,0xACAC00A0,0x440000AC,0x14000000,
0x1C000018,0x20000024,0x2C000030,0x30000040,0x38000050,0x40000060,0x4404006C,0x4C000074,0x54080078,0x6018007C,0x6C280088,0x7C3C0090,0x844C0098,0x3C0000A0,0x14140000,0x1C1C0014,
0x2828001C,0x34340028,0x40400034,0x4C4C0040,0x5858004C,0x64640058,0x6C6C0064,0x7878006C,0x84840078,0x90900084,0x9C9C0090,0xA8A8009C,0xB4B400A8,0xC0C000B4,0xCCCC00C0,0xD8D800CC,
0x343400D8,0x44400044,0x54500054,0x64600068,0x78700078,0x8880008C,0x9C90009C,0xB0A400B0,0xC4B400C0,0x485800D4,0x5C6C0030,0x74800044,0x8C94005C,0x9CA4007C,0x14000090,0x18000024,
0x2000002C,0x24040034,0x2C04003C,0x30080048,0x380C0050,0x40140058,0x4C180064,0x581C006C,0x60240078,0x6C280080,0x7830008C,0x84380094,0x944000A0,0xA04800A8,0x340000B4,0x40000018,
0x4C00001C,0x58000024,0x64040028,0x70040030,0x80080034,0x8810003C,0x9414004C,0xA018005C,0xAC20006C,0xB828007C,0x34140090,0x48140074,0x6418009C,0x841400C4,0x000000F0,0x00000018,
0x0000002C,0x00000044,0x0000005C,0x00000074,0x00000088,0x000000A0,0x000000B8,0x381000D0,0x4C1C0060,0x64280074,0x7C3C0088,0x9054009C,0xA87400B4,0xC49800CC,0x002400E8,0x00300000,
0x04400000,0x0C4C0000,0x185C0000,0x28700000,0x34780000,0x40840004,0x5090000C,0x60980018,0x70A40024,0x80B00034,0xF4580044,0xB43800FC,0x601800FC,0x000000FC,0x300000FC,0x4000005C,
0x50040068,0x64080078,0x780C0088,0x8C100098,0xA41400A8,0xC01C00BC,0xE02000D0,0x000000F4,0x000000FC,0x94FC00B0,0xD0000000,0x000000FC,0x00FC00FC,0xFC000000,0,0x000000A4,
0x0400007C,0x0400005C,0x48CC0044,0x28A0000C,0x14740004,0x044C0000,0xB4940000,0x845C002C,0x542C0014,0x280C0004,0x48B00000,0x2C840098,0x18580074,0x082C0050,0x8C14002C,0x601000F8,
0x3C1000C8,0x200C0098,0x283C006C,0x1C2C0028,0x1420001C,0x0C140014,0xE0E0000C,0x98B400E0,0x54800098,0x284C0054,0x40140024,0x58200068,0x7030007C,0x00000090,0x5CA00000,0x34780018,
0x50840004,0x6C8C0010,0x80E40018,0x8448001C,0xF8F000A8,0xA0A400FC,0x808000A0,0x00000080,0xFC0000FC,0xFC000000,0x00FC00FC,0x00FC0000,0xFCFC00FC,0xFCFC0000,0x000000FC,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
BYTE* bmptr = (BYTE*)bmp8;
BYTE* pixmap;
int linew,bmw,bmh;
void init_bmp(int w,int h){
// initialize the bitmap buffer for the supplied size
BITMAPFILEHEADER* bfh = (BITMAPFILEHEADER*)bmptr;
BITMAPINFOHEADER* bih = (BITMAPINFOHEADER*)(bmptr+sizeof(BITMAPFILEHEADER));
pixmap = bmptr+bfh->bfOffBits;
linew = ((w+3)>>2)<<2;
int psize = linew*h;
bfh->bfSize = bfh->bfOffBits+psize;
bih->biWidth = w;
bih->biHeight= h;
bmw = bih->biWidth;
bmh = bih->biHeight;
FillMemory(pixmap,psize,BG_COLOR);
}
void set_pixel(int x,int y,int c){
// set a pixel in the current bitmap
BYTE* pptr = pixmap+(linew*(bmh-y-1))+x;
*pptr = c;
}
int get_pixel(int x,int y){
// get a pixel from the current bitmap
BYTE* pptr = pixmap+(linew*(bmh-y-1))+x;
return *pptr;
}
void normalize_bmp(){
// change palette indexes to font indexes
// change unknown values to transparent
int c;
for(int y=0;y<bmh;y++){
for(int x=0;x<bmw;x++){
c = get_pixel(x,y);
set_pixel(x,y,0);
for(int i=0;i<=5;i++){
if(c==clrndx[i]){
set_pixel(x,y,i);
break;
}
}
}
}
}
int bmp_yos(){
// find non-zero Y offset
for(int y=0;y<bmh;y++){
for(int x=0;x<bmw;x++){
if(get_pixel(x,y)!=0)return y;
}
}
return -1;
}
int bmp_xos(){
// find non-zero X offset
for(int x=0;x<bmw;x++){
for(int y=0;y<bmh;y++){
if(get_pixel(x,y)!=0)return x;
}
}
return -1;
}
BOOL save_bmp(char* path){
// save the current bitmap
BITMAPFILEHEADER* bfh = (BITMAPFILEHEADER*)bmptr;
HANDLE fn = CreateFile(path,GENERIC_WRITE,FILE_SHARE_WRITE,0,CREATE_ALWAYS,0,0);
DWORD nb;
if(fn!=INVALID_HANDLE_VALUE){
if(WriteFile(fn,bmptr,bfh->bfSize,&nb,NULL)){
CloseHandle(fn);
return TRUE;
}
CloseHandle(fn);
}
return FALSE;
}
BOOL load_bmp(char* path){
BITMAPFILEHEADER* bfh = (BITMAPFILEHEADER*)bmptr;
BITMAPINFOHEADER* bih = (BITMAPINFOHEADER*)(bmptr+sizeof(BITMAPFILEHEADER));
HANDLE fn = CreateFile(path,GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,0,0);
DWORD nb;
if(fn!=INVALID_HANDLE_VALUE){
loadlen = GetFileSize(fn,NULL);
// read file into buffer
ReadFile(fn,bmp8, loadlen, &nb, NULL);
CloseHandle(fn);
if(nb==loadlen){
bmw = bih->biWidth;
bmh = bih->biHeight;
pixmap = bmptr+bfh->bfOffBits;
linew = ((bmw+3)>>2)<<2;
return TRUE;
}
}
return FALSE;
}
BITMAPINFOHEADER* bmp_info(){
return (BITMAPINFOHEADER*)(bmptr+sizeof(BITMAPFILEHEADER));
}
// --- EXTRACT --- //
BOOL extract_char(HANDLE hFont,int base,int c,char* path){
FontLetterRaw* flr;
BYTE* bptr = (BYTE*)hFont;
DWORD* dptr = (DWORD*)hFont;
int px = 0;
int py = 0;
// get file offset
dptr += (c-base+2);
if(!(*dptr))return FALSE;
bptr +=(*dptr);
// read character header
flr =(FontLetterRaw*)bptr;
bptr += sizeof(FontLetterRaw);
// initialize output bitmap
init_bmp( flr->Width+flr->XOffset, flr->Height+flr->YOffset );
// set pixels
while(py<flr->Height){
// read data byte
c = *bptr;
bptr++;
// apply shift
px+=(c>>3);
c&=7;
// wrap
while(px>=flr->Width){
px -= flr->Width;
py++;
}
// set pixel
if(c&&py<flr->Height){
set_pixel( px+flr->XOffset, py+flr->YOffset, clrndx[c] );
px++;
}
}
save_bmp(path);
}
BOOL test4cc(char* a,char* b){
for(int i=0;i<4;i++){
if(*a!=*b)return FALSE;
a++;
b++;
}
return TRUE;
}
int do_extract(char* path){
FontHeader* fh;
char* bpath;
HANDLE hFont = bload(path);
if(hFont!=NULL){
// verify 4CC
if(test4cc((char*)szFont4cc,(char*)hFont)){
// prepare output path
lstrcpy(pathbuf,path);
bpath = get_extension(pathbuf)-1;
// read the file header
fh = (FontHeader*)hFont;
// process the characters
for(int c=fh->LowIndex;c<=fh->HighIndex;c++){
// make bmp filename
wsprintf(bpath,szBmpTmpl,c);
// extract the character
extract_char(hFont,fh->LowIndex,c,pathbuf);
}
GlobalFree(hFont);
return EXIT_SUCCESS;
}
GlobalFree(hFont);
return INVALID_FILE;
}
return READ_ERROR;
}
// --- COMPILE --- //
int compile_char(BYTE* optr){
// write raw data for current bmp char at optr
// return data size in bytes
int c,t;
FontLetterRaw* flr = (FontLetterRaw*)optr;
optr+=sizeof(FontLetterRaw);
// set character header
int yos = bmp_yos();
if(yos==-1)return 0;
flr->YOffset = yos;
flr->XOffset = bmp_xos();
flr->Width = bmw-flr->XOffset;
flr->Height = bmh-flr->YOffset;
// compile pixels
t=0;
for(int y=flr->YOffset;y<bmh;y++){
for(int x=flr->XOffset;x<bmw;x++){
c=get_pixel(x,y);
if(c){
*optr=(t<<3)+c;
t=0;
optr++;
}else{
t++;
if(t==31){
*optr=0xF8;
optr++;
t=0;
}
}
}
}
if(t){
*optr=(t<<3);
optr++;
}
return (int)optr-(int)flr;
}
int do_compile(CHAR* path){
HANDLE fn;
DWORD nb;
int len;
BITMAPINFOHEADER* bih;
FontHeader* fh;
BYTE* hFont;
char* bpath;
DWORD* fptr;
BYTE* optr;
int datsize;
int maxw = 0;
int maxh = 0;
int minc = 0x20;
int maxc = 0;
int nchar= 0;
// enum char bitmaps
lstrcpy(pathbuf,path);
bpath = get_extension(pathbuf)-5;
for(int i=1;i<256;i++){
wsprintf(bpath,szBmpTmpl,i);
if(PathFileExists(pathbuf)){
if(get_flen(pathbuf)<=bmp8len){
if(i<minc)minc=i;
if(i>maxc)maxc=i;
load_bmp(pathbuf);
bih = bmp_info();
if(bih->biWidth>maxw)maxw=bih->biWidth;
if(bih->biHeight>maxh)maxh=bih->biHeight;
}
}
}
if(!maxw*maxh*maxc)return INVALID_INPUT;
if(maxc<minc){ minc=maxc; maxc=0x20; }
nchar = maxc-minc+1;
// allocate output buffer
hFont = (BYTE*)GlobalAlloc(GPTR,nchar*MAX_CHAR_SIZE);
if(!hFont)return ALLOC_FAIL;
// set up pointers
fh=(FontHeader*)hFont;
fptr=(DWORD*)(hFont+sizeof(FontHeader));
optr=(BYTE*)(hFont+sizeof(FontHeader)+nchar*4);
// write font header
lstrcpy((char*)hFont,szFont4cc);
fh->LowIndex = minc;
fh->HighIndex = maxc;
fh->MaxWidth = maxw;
fh->MaxHeight = maxh;
// compile characters
for(int c=minc;c<=maxc;c++){
datsize = 0;
wsprintf(bpath,szBmpTmpl,c);
if(PathFileExists(pathbuf)){
len = get_flen(pathbuf);
if(len&&len<=bmp8len){
if(!load_bmp(pathbuf)){
GlobalFree(hFont);
return READ_ERROR;
}
normalize_bmp();
datsize = compile_char(optr);
}
}
// write file offset
if(datsize)*fptr=optr-hFont;
fptr++;
optr+=datsize;
}
// write fnt file
datsize=optr-hFont;
lstrcpy(bpath,szFntTmpl);
fn = CreateFile(pathbuf,GENERIC_WRITE,FILE_SHARE_WRITE,0,CREATE_ALWAYS,0,0);
if(fn==INVALID_HANDLE_VALUE){
GlobalFree(hFont);
return WRITE_ERROR;
}else{
if(WriteFile(fn,hFont,datsize,&nb,NULL)){
CloseHandle(fn);
GlobalFree(hFont);
if(nb==datsize)return 0;
return WRITE_ERROR;
}
CloseHandle(fn);
GlobalFree(hFont);
return WRITE_ERROR;
}
}
// --- HELP --- //
int do_help(){
MessageBox(0,szHelpText,"War2 Font Tool",0);
return EXIT_SUCCESS;
}
// --- MAIN --- //
int main(int argc, char *argv[]){
CHAR* e;
if(lstrlen(argv[1])>3){
e=get_extension(argv[1]);
if(lstrlen(e)!=3)return INVALID_FILE;
if(!lstrcmpi(e,f_ext))return do_extract(argv[1]);
if(!lstrcmpi(e,b_ext))return do_compile(argv[1]);
}else{
return do_help();
}
}
Interesting... I had a whole different idea, my plan was to create a wsock32 proxy that works with any version of the game (without any kind of game patches).
I wanted to catch the packet that's being sent when you try to join a room, take it and append a id (a crc32 of the host's name possibly) and forward it to a server. The server will now forward the packet to the host (It knows where to send it, it reads the id) and appends the IP/Port of the sender. The host will now receive the packet from the server containing the original senders IP/Port, he will now send a packet to the original sender and that's pretty much it, holepunching is done :)
For this to work I would've created another thread that keeps sending a keep alive packet each 30seconds or so to the server, this is where the players announce their ids. The server will save the id/ip+port combo and store it, this way it always knows where to forward the packets when someone tries to join a game.
This is supposed to be a fully UDP solution, no changes or any kind of interaction with the pvpgn server are required.
im not seeing the map as a host? installed to 2.02 bnet and created tvb
Have you ever seen that program that automatically generates a new map? That would be a cool plug-in, host runs it and it generates the map and then you host, and instead of showing the thumbnail preview it shows a big "?" and everyone has to explore, because nobody has seen it...
im not seeing the map as a host?
#include <windows.h>
// export a "w2p_init()" function this will run once when wc2 loads
extern "C" __declspec (dllexport) void w2p_init(){
// declare a pointer to a BYTE
BYTE* bytePointer;
// make it point to the mini-map black location
bytePointer = (BYTE*)0x4A48B1;
// set the byte to grey (0xEA)
*bytePointer = 0xEA;
// ...could also use
// - 0xFD Bright Pink
// - 0xDE Dark Purple
// - 0xD2 Dark Red
// - 0xE3 Dark OJ
}
BOOL APIENTRY DllMain ( HINSTANCE hInst, DWORD reason, LPVOID reserved ){ return TRUE; }
Mini-Map Black to Grey Plugin
Changes the mini-map display color for the black player to a lighter shade of grey.
This is a very simple plugin that just changes 1 byte in the wc2 process, heres the source:Code: [Select]#include <windows.h>
// export a "w2p_init()" function this will run once when wc2 loads
extern "C" __declspec (dllexport) void w2p_init(){
// declare a pointer to a BYTE
BYTE* bytePointer;
// make it point to the mini-map black location
bytePointer = (BYTE*)0x4A48B1;
// set the byte to grey (0xEA)
*bytePointer = 0xEA;
// ...could also use
// - 0xFD Bright Pink
// - 0xDE Dark Purple
// - 0xD2 Dark Red
// - 0xE3 Dark OJ
}
BOOL APIENTRY DllMain ( HINSTANCE hInst, DWORD reason, LPVOID reserved ){ return TRUE; }
Just build that as a DLL file then change the filename from .dll to .w2p and put it in the "plugin" folder.
This source can be easily modified to test other mods also if you want.
Any functionality to draw to warcraft 2 screen? What about an array of bytes sample also. It would then be perfect to project! Thanks brother.
//
/////////////////////////////////////////////////////
// Example dll for Warcraft II plugin framework //
/////////////////////////////////////////////////////
// Lambchops 2019
// *** This is a poor way of implementing a game timer.
// Shoud really be re-written to use GetSystemTime() or similar,
// but it makes for a simple example this way.
#include <windows.h>
#include <lamb.h>
// constants for the in-game screen
#define LOC_INGAME_H 1684300900
#define LOC_INGAME_O 2155905153
// display the timer here
// * using the top of mini-map to guarantee that this part
// of the screen is updated every second *
#define CLOCK_X 22
#define CLOCK_Y 24
// color for pixels on timer bitmap
#define CLOCK_COLOR 0xFE
BOOL game_timer_on = FALSE;
// count the number of game ended signals
BOOL tick_out = 0;
int game_secs = 0;
int game_mins = 0;
int game_hours = 0;
int game_days = 0;
// allocate a buffer to store timer as a string
CHAR clockbuf[16];
// create a little 32x6 bitmap to draw timer string on to
HMIBMP* clock = make_bitmap(32,6,8);
// temp storage for game "location" value supplied
// to "screen_update()" by the framework
DWORD loc;
BOOL in_game(){
// return TRUE if we are in a game
return (loc==LOC_INGAME_H||loc==LOC_INGAME_O);
}
void reset_timer(){
tick_out = 0;
game_secs = -1;
game_mins = 0;
game_hours= 0;
game_days = 0;
}
void game_tick(){
// add 1 second to game time
game_secs++;
if(game_secs==60){
game_secs=0;
game_mins++;
if(game_mins==60){
game_mins=0;
game_hours++;
if(game_hours==24){
game_hours=0;
game_days++;
}
}
}
// redraw the timer display bitmap //
wsprintf(&clockbuf[0],"%2.2d:%2.2d:%2.2d",game_hours,game_mins,game_secs);
zero_bitmap(clock);
paste_string(clock,0,0,&clockbuf[0],4,CLOCK_COLOR);
}
void CALLBACK TimerProc(HWND hwnd,UINT uMsg,UINT idEvent,DWORD dwTime){
// this is called every 1 second by the system timer we set up below
if(game_timer_on){
if(in_game()){
// update time by 1 second
game_tick();
tick_out = 0;
}else{
if(tick_out>1){
// = 3rd miss for in_game()
//( location constant appears to occasionally glitch on
// some systems - possibly a ddraw thing ?? )
// game ended
game_timer_on = FALSE;
}else{
game_tick();
tick_out++;
}
}
}else{
if(in_game()){
// game started
game_timer_on = TRUE;
reset_timer();
game_tick();
}
}
}
////// EXPORTED FUNCTIONS FOR THE FRAMEWORK TO CALL ///////
// called once at startup
extern "C" __declspec (dllexport) void w2p_init(){
// Create a timer that ticks every 1 second
SetTimer(NULL,0,1000,TimerProc);
}
// called every screen update
extern "C" __declspec (dllexport) void screen_update(DWORD location){
loc=location;
if(game_timer_on){
// paste the time display bitmap onto the game screen ( pixel 0 = transparent )
wc2_trans_paste(clock,CLOCK_X,CLOCK_Y);
}
}
BOOL APIENTRY DllMain ( HINSTANCE hInst, DWORD reason, LPVOID reserved ){ return TRUE; }
#include <windows.h>
#ifndef _LAMB_
#define _LAMB_
extern "C" {
typedef struct hmibmp {
BITMAPFILEHEADER* pFile;
BITMAPINFOHEADER* pInfo;
RGBQUAD* pPal;
BYTE* pBits;
int width;
int height;
int bpp;
int linew;
int usage;
int size;
}HMIBMP;
}
//hmibmp.inc
extern "C" typedef HMIBMP* (__stdcall *pfnmakebmp )(int w,int h,int bpp);
extern "C" typedef void (__stdcall *pfnfreebmp )(HMIBMP* bmp);
extern "C" typedef int (__stdcall *pfnzerobmp )(HMIBMP* bmp);
extern "C" typedef void (__stdcall *pfnsavebmp )(CHAR* path,HMIBMP* bmp);
extern "C" typedef void (__stdcall *pfnsavejpg )(CHAR* path,HMIBMP* bmp,int quality);
extern "C" typedef void (__stdcall *pfnperfbmp )(HMIBMP* bmp);
extern "C" typedef void (__stdcall *pfncopyimg )(HMIBMP* src,int scrx,int srcy,int srcw,int scrh,HMIBMP* dst,int dstx,int dsty,int transp);
extern "C" typedef int (__stdcall *pfncopyfull)(HMIBMP* dstbmp,HMIBMP* srcbmp,int transp);
extern "C" typedef void (__stdcall *pfndispimg )(HDC destDC,int x,int y,int w,int h,HMIBMP* bmp,int dx,int dy,int dw,int dh);
extern "C" typedef void (__stdcall *pfnsetpal )(HMIBMP* bmp,LPVOID palette);
extern "C" typedef void (__stdcall *pfndrawrect)(HMIBMP* bmp,int x,int y,int w,int h,int color);
extern "C" typedef HMIBMP* (__stdcall *pfnsizebmp )(HMIBMP* bmp,int w,int h);
extern "C" typedef HMIBMP* (__stdcall *pfnscalebmp)(HMIBMP* bmp,int scale);
extern "C" typedef void (__stdcall *pfnsetpixel)(HMIBMP* bmp,int x,int y,int pval);
extern "C" typedef void (__stdcall *pfnpastestr)(HMIBMP* bmp,int x,int y,CHAR* lpsz,int point,int color);
extern "C" typedef void (__stdcall *pfnwc2tpast)(HMIBMP* bmp,int x,int y);
extern pfnmakebmp make_bitmap;
extern pfnfreebmp free_bitmap;
extern pfnzerobmp zero_bitmap;
extern pfnsavebmp save_bitmap;
extern pfnsavejpg save_jpeg;
extern pfnperfbmp perforate_bitmap;
extern pfncopyimg copy_image;
extern pfncopyfull copy_full_image;
extern pfndispimg display_image;
extern pfnsetpal set_palette;
extern pfndrawrect draw_rect;
extern pfnsizebmp size_bitmap;
extern pfnscalebmp scale_bitmap;
extern pfnsetpixel set_pixel;
extern pfnpastestr paste_string;
extern pfnwc2tpast wc2_trans_paste;
#endif
#include <windows.h>
#include <lamb.h>
HMODULE hLambDll = LoadLibraryA("LC");
pfnmakebmp make_bitmap = (pfnmakebmp )GetProcAddress(hLambDll, "make_bitmap" );
pfnfreebmp free_bitmap = (pfnfreebmp )GetProcAddress(hLambDll, "free_bitmap" );
pfnzerobmp zero_bitmap = (pfnzerobmp )GetProcAddress(hLambDll, "zero_bitmap" );
pfnsavebmp save_bitmap = (pfnsavebmp )GetProcAddress(hLambDll, "save_bitmap" );
pfnsavejpg save_jpeg = (pfnsavejpg )GetProcAddress(hLambDll, "save_jpeg" );
pfnsizebmp size_bitmap = (pfnsizebmp )GetProcAddress(hLambDll, "size_bitmap" );
pfnscalebmp scale_bitmap = (pfnscalebmp)GetProcAddress(hLambDll, "scale_bitmap" );
pfnperfbmp perforate_bitmap = (pfnperfbmp )GetProcAddress(hLambDll, "perforate_bitmap" );
pfncopyimg copy_image = (pfncopyimg )GetProcAddress(hLambDll, "copy_image" );
pfncopyfull copy_full_image = (pfncopyfull)GetProcAddress(hLambDll, "copy_full_image" );
pfndispimg display_image = (pfndispimg )GetProcAddress(hLambDll, "display_td_image" );
pfnsetpal set_palette = (pfnsetpal )GetProcAddress(hLambDll, "set_palette" );
pfndrawrect draw_rect = (pfndrawrect)GetProcAddress(hLambDll, "draw_rect" );
pfnsetpixel set_pixel = (pfnsetpixel)GetProcAddress(hLambDll, "set_pixel" );
pfnpastestr paste_string = (pfnpastestr)GetProcAddress(hLambDll, "paste_string" );
pfnwc2tpast wc2_trans_paste = (pfnwc2tpast)GetProcAddress(hLambDll, "wc2_trans_paste" );
Warcraft II Plugin Framework
( including demo plugins )
This will install a small file called "LC.dll" and make a few modifications to Warcraft II BNE.exe that link it.
A "plugins" folder will be created in the wc2 folder. Plugins can be placed in this folder will be automatically loaded when you run wc2.
This will allow a variety of mods to be easilly installed/uninstalled by users.
If there is nothing in the "plugins" folder, there is no change to how the game functions.
-------------
For developers:SpoilerA plugin is simply a dll file that has the extension changed to "w2p".
There are currently only 3 hook points, although I may add more in the future if there is a demand.
The hook points can be accessed by exporting appropriately named functions from a plugin dll.
w2p_init has no arguments and is called when the exe is first started.
create_game will be passed a pointer to the game name and called when the player creates a game.
join_game will be passed a pointer to the game name and called when the player joins a game.
screen_update will be passed a value that describes the current game screen and will be called immediately before each screen update.
... so to make a simple plugin all you need to do is make a dll file that exports one function called "w2p_init" that takes no agruments, then rename it to "MyPlugin.w2p" or whatever and put it into the "plugins" folder. Your plugin will then be injected into the WC2 process when you next run it.
I will try to do some examples later when time allows.
---------
There are 4 example plugins included. If you don't want any of them, you can disable/enable them individually just by moving them in or out of the plugins folder (of course exit WC2 first then restart).
----------
The "Lobby Map" plugin
([url]http://forum.war2.ru/index.php?action=dlattach;topic=4910.0;attach=3008[/url])
The "lobby map" Plugin gives you a preview of the map in the pre-game lobby.
-----------------
The "Game Time" plugin
([url]http://forum.war2.ru/index.php?action=dlattach;topic=2703.0;attach=3019[/url])
The "Game Time" plugin just adds a small game timer to the in game screen.
--------------
The "Chop Bars" plugin
([url]http://forum.war2.ru/index.php?action=dlattach;topic=2703.0;attach=3017[/url])
The "Chop Bars" plugin gives you an on-screen progress bar for chopping peons that you own and are selected.
------------
The "Allied Colors" plugin
([url]http://forum.war2.ru/index.php?action=dlattach;topic=2703.0;attach=2177[/url])
The "Allied Colors" plugin give you the option of displaying all allies in blue and all enemies in red on the mini-map.
Press F2 to toggle this on/off. It is off by default.
----------------------
To install download the zip file and copy/replace its contents into a combat43 installation.
*Should also work for any versions earlier than 4.3 - AFAIK they all use the same wc2 .exe file.
Currently tested and working with Windows 10, 7 and XP.
----------------------
This is still in development, but appears to be working and stable for me .... please test! :)
Note: The plugin framework currently only supports BNE 2.02 (Combat Edition 4.3 or earlier), it does not support CE 4.4 or the GOG version. If there is a demand it can be ported at a later date.
:critter:
The same for War1. This allows to avoid back tiles layer redrawing every time. Also as I remember this feature is used for building frame coloring.
i finally got the plugin system installed & it's really nice!! it's working for the non-latest version of war2combat & the latest version of fois's ddraw with the moveable window, but i did notice 2 things:
- the map in game lobby disappears & reappears randomly, sometimes when alt-tabbing
- the new warcraft ii bne.exe kills insight? I get this popup when i click "record"
also jw is the CpuSaveC.w2p the same as the console cpu savior?