War2.ru Slogan
News: If your graphics are broken you can fix with the new ddraw version.
** Read how to install it here **


Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
Welcome to the forums! We're glad to have you here! :) You can register your account here, then feel free to introduce yourself in the Server.War2.ru board & let us know who you are on the server.

Nerd's Corner 12950  176

Death Knight Posts: 3259 Karma: +78/-2 retired, be in music section *********

easycompany

  • Death Knight
  • *********
  • Posts: 3259
  • retired, be in music section
    • View Profile
Re: Nerd's Corner
« Reply #165 on: May 02, 2019, 09:40:57 AM »
im not seeing the map as a host?  installed to 2.02 bnet and created tvb
Ogre Posts: 1210 Karma: +77/-0 *******

Lambchops

  • Ogre
  • *******
  • *
  • Posts: 1210
    • View Profile
Re: Nerd's Corner
« Reply #166 on: May 02, 2019, 09:51:34 AM »
im not seeing the map as a host?  installed to 2.02 bnet and created tvb


--- edit ---


This problem fixed with v0.1.2

( was an issue with custom ddraw )
Death Knight Posts: 3259 Karma: +78/-2 retired, be in music section *********

easycompany

  • Death Knight
  • *********
  • Posts: 3259
  • retired, be in music section
    • View Profile
Re: Nerd's Corner
« Reply #167 on: May 02, 2019, 10:07:26 AM »
win7 here ...yeah redone it to my ru version thats outside program files...still not getting to display.

its more than likely me ..need another machine to test.
Death Knight Posts: 3259 Karma: +78/-2 retired, be in music section *********

easycompany

  • Death Knight
  • *********
  • Posts: 3259
  • retired, be in music section
    • View Profile
Re: Nerd's Corner
« Reply #168 on: May 02, 2019, 10:42:04 AM »
yup lc and lamb   wait and let someone else test my machine is a known pos..blue screens the works
Death Knight Posts: 3259 Karma: +78/-2 retired, be in music section *********

easycompany

  • Death Knight
  • *********
  • Posts: 3259
  • retired, be in music section
    • View Profile
Re: Nerd's Corner
« Reply #169 on: May 03, 2019, 10:24:28 AM »
what os you on lamb?  ive tried everything u said still zip.
"The Architect" Global Moderator Dragon Posts: 5001 Karma: +198/-111 *****

Certified MENSA Genius Brain (smart)

  • "The Architect"
  • Global Moderator
  • Dragon
  • *****
  • *
  • Posts: 5001
    • View Profile
Re: Nerd's Corner
« Reply #170 on: May 03, 2019, 10:40:38 AM »
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...
Death Knight Posts: 3259 Karma: +78/-2 retired, be in music section *********

easycompany

  • Death Knight
  • *********
  • Posts: 3259
  • retired, be in music section
    • View Profile
Re: Nerd's Corner
« Reply #171 on: May 03, 2019, 11:08:31 AM »
warcraft 2 randomizer
Ogre Posts: 1210 Karma: +77/-0 *******

Lambchops

  • Ogre
  • *******
  • *
  • Posts: 1210
    • View Profile
Re: Nerd's Corner
« Reply #172 on: May 03, 2019, 11:28:02 AM »
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...

Yeah that would be cool. You could make a plugin that makes a random map and hosts it, but people could still look at the pud file and cheat...

Have you tested the plugin framework yet? :)

Ogre Posts: 1210 Karma: +77/-0 *******

Lambchops

  • Ogre
  • *******
  • *
  • Posts: 1210
    • View Profile
Re: Nerd's Corner
« Reply #173 on: May 19, 2019, 10:29:26 AM »
im not seeing the map as a host?



Turns out the updated ddraw.dll that a lot of people are using is great for the game but is missing most of the standard Windows API functionality so the methods I was using to display things on the screen were not working with that.

V0.1.2 Hooks the WC2 internal screen update so is compatible with all direct draw versions.

V0.1.3 Has fixed compatibility issues with later versions of windows.


Have updated THIS post with the new version.


Please Test :)



Ogre Posts: 1210 Karma: +77/-0 *******

Lambchops

  • Ogre
  • *******
  • *
  • Posts: 1210
    • View Profile
Re: Nerd's Corner
« Reply #174 on: June 13, 2019, 02:39:32 AM »

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.



Death Knight Posts: 2553 Karma: +82/-4 *********

tupac

  • Death Knight
  • *********
  • *
  • Posts: 2553
    • View Profile
Re: Nerd's Corner
« Reply #175 on: June 13, 2019, 08:56:24 PM »

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.
Ogre Posts: 1210 Karma: +77/-0 *******

Lambchops

  • Ogre
  • *******
  • *
  • Posts: 1210
    • View Profile
Re: Nerd's Corner
« Reply #176 on: June 13, 2019, 10:41:59 PM »

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.


Yeah sure. Sorry not finding much time to document all of this.... still working 6 days a week ( and sleeping 1 day )

For an array of bytes, you can just declare the array in your source then use memcpy or CopyMemory etc. Will try to do an example later, but you can probably work that out.

Here's the game timer plugin. It demonstrates writing a string on a bitmap, then pasting that bitmap to the wc2 screen inside the display hook.

... uses:

paste_string(clock,0,0,&clockbuf[0],4,CLOCK_COLOR);

clock is the bitmap handle
(0,0) is target co-ords on the bitmap
&clockbuf[0] is the source ANSI string
4 is the font size (only supports 4 and 6 currently)
CLOCK_COLOR is the pixel value to set on the bitmap

this is done once per second to update the bitmap, then in the sccreen display hook it uses:

wc2_trans_paste(clock,CLOCK_X,CLOCK_Y);

to paste the "clock" bitmap onto the screen buffer at co-ords (CLOCK_X,CLOCK_Y)
(assumes 0 pixels are transparent)

These functions are exported from LC.dll
Have a look at lamb.h and lamb.cpp for others

Will try to document these further later.



dllmain.cpp
Code: [Select]
                                                         //
     /////////////////////////////////////////////////////
    //   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;

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(){
    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();
        }else{
            // game ended
            game_timer_on = FALSE;
        }
    }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; }



lamb.h
Code: [Select]
#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

lamb.cpp

Code: [Select]
#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"     );