Jibble

Author Topic: A custom plugin is throwing an error on Win 7 [SOLVED]  (Read 447 times)

Dualnames

  • AGS Baker
  • Pretty Badass
    • Dualnames worked on one or more games that won an AGS Award!
    •  
    • Dualnames worked on one or more games that was nominated for an AGS Award!
So apparently 2/3rds of the Primordia squad, are using WINDOWS 7. I compiled a plugin recently, and I send the files over and they had two errors.
Error 1:
MSCVR100d.dll is missing

and
Error 2: Script link failed: Runtime error: unresolved import 'DrawScreenEffect'

(That is a custom function of the plugin).

Anyhows, so Error 1, has been fixed I recompiled the plugin with Visual Studio 08, but Error 2 remains, I thought maybe I should rebuild all files of the game, and reupload, which is what I'm in the process of doing. I don't mind sharing the plugin, and/or it's full code.

http://primordia-game.com/Files0/agswavev2.rar

In fact here it is.

Code: Adventure Game Studio
  1.  
  2.  
  3. #ifdef WIN32
  4. #define WINDOWS_VERSION
  5. #define WIN32_LEAN_AND_MEAN
  6. #include <windows.h>
  7. #pragma warning(disable : 4244)
  8. #endif
  9.  
  10. #if !defined(BUILTIN_PLUGINS)
  11. #define THIS_IS_THE_PLUGIN
  12. #endif
  13.  
  14. #include <stdlib.h>
  15. #include <stdio.h>
  16. //#include <string.h>
  17. //#include <math.h>
  18. //#include <stdint.h>
  19.  
  20. #if defined(PSP_VERSION)
  21. #include <pspsdk.h>
  22. #include <pspmath.h>
  23. #include <pspdisplay.h>
  24. #define sin(x) vfpu_sinf(x)
  25. #endif
  26.  
  27. #include "plugin/agsplugin.h"
  28.  
  29. #if defined(BUILTIN_PLUGINS)
  30. namespace agswave {
  31. #endif
  32.  
  33. #if defined(__GNUC__)
  34. inline unsigned long _blender_alpha16_bgr(unsigned long y) __attribute__((always_inline));
  35. inline void calc_x_n(unsigned long bla) __attribute__((always_inline));
  36. #endif
  37.  
  38. const unsigned int Magic = 0xBABE0000;
  39. const unsigned int Version = 1;
  40. const unsigned int SaveMagic = Magic + Version;
  41. const float PI = 3.14159265f;
  42.  
  43. int screen_width = 640;
  44. int screen_height = 360;
  45. int screen_color_depth = 32;
  46.  
  47. IAGSEngine* engine;
  48.  
  49.  
  50.  
  51. // Imported script functions
  52.  
  53.  
  54.  
  55. int dY=0;
  56. int tDy=0;
  57. int direction=0;
  58.  
  59. void CastWave(int delayMax, int PixelsWide)
  60. {
  61.   tDy++;
  62.   if (tDy >delayMax)
  63.   {
  64.     tDy=0;
  65.     if (direction==0) dY++;
  66.         if (direction==1) dY--;
  67.         if ( (dY>PixelsWide && direction==0) || (dY<-PixelsWide && direction==1) )
  68.         {
  69.                 if (direction==0){dY=PixelsWide;direction=1;}
  70.                 else {dY=-PixelsWide;direction=0;}
  71.         }
  72.   }
  73.  
  74.  
  75. }
  76.  
  77.  
  78.  
  79.  
  80.  
  81. void DrawEffect(int sprite_a,int sprite_b,int id)
  82. {
  83.   int x, y;
  84.  
  85.   BITMAP* src_a = engine->GetSpriteGraphic(sprite_a);
  86.   BITMAP* src_b = engine->GetSpriteGraphic(sprite_b);
  87.  
  88.   unsigned int** pixel_a = (unsigned int**)engine->GetRawBitmapSurface(src_a);
  89.   unsigned int** pixel_b = (unsigned int**)engine->GetRawBitmapSurface(src_b);
  90.  
  91.   for (y = 0; y < screen_height; y++)
  92.   {
  93.     if (id==0) CastWave(2,1);
  94.         if (id==1) CastWave(15,1);
  95.        
  96.     for (x = 0; x < screen_width; x++)
  97.     {
  98.           unsigned int colorfromB = pixel_b[y][x];
  99.           int getX=x;
  100.           int getY=y;
  101.  
  102.           if (id==0)
  103.           {
  104.                   getX=x-(rand() % 2)-2;
  105.                   getY=y+dY;
  106.           }
  107.           if (id==1)
  108.           {
  109.                   getX=x;
  110.                   getY=y+dY;
  111.           }
  112.           if (getX < 0) getX=0;
  113.           if (getX > screen_width-1) getX = screen_width-1;
  114.           if (getY > screen_height-1) getY = screen_height-1;
  115.           if (getY < 0) getY = 0;
  116.          
  117.  
  118.           pixel_a[getY][getX]=colorfromB;         //
  119.     }
  120.   }
  121.   engine->ReleaseBitmapSurface(src_a);
  122.   engine->ReleaseBitmapSurface(src_b);
  123.  
  124. }
  125.  
  126.  
  127. void RestoreGame(FILE* file)
  128. {
  129.   unsigned int Position = ftell(file);
  130.   unsigned int DataSize;
  131.  
  132.   unsigned int SaveVersion = 0;
  133.   fread(&SaveVersion, 4, 1, file);
  134.  
  135.   if (SaveVersion == SaveMagic)
  136.   {
  137.     fread(&DataSize, 4, 1, file);
  138.  
  139.     // Current version
  140.    
  141.  
  142.     //fread(&g_DarknessLightLevel, 4, 1, file);
  143.    
  144.        
  145.   }
  146.   else if ((SaveVersion & 0xFFFF0000) == Magic)
  147.   {
  148.     // Unsupported version, skip it
  149.     DataSize = 0;
  150.     fread(&DataSize, 4, 1, file);
  151.  
  152.     fseek(file, Position + DataSize - 8, SEEK_SET);
  153.   }
  154.   else
  155.   {
  156.     // Unknown data, loading might fail but we cannot help it
  157.     fseek(file, Position, SEEK_SET);
  158.   }
  159. }
  160.  
  161.  
  162. void SaveGame(FILE* file)
  163. {
  164.   unsigned int StartPosition = ftell(file);
  165.  
  166.   fwrite(&SaveMagic, 4, 1, file);
  167.   fwrite(&StartPosition, 4, 1, file); // Update later with the correct size
  168.  
  169.  
  170.   //fwrite(&g_DarknessLightLevel, 4, 1, file);
  171.  
  172.  
  173.   unsigned int EndPosition = ftell(file);
  174.   unsigned int SaveSize = EndPosition - StartPosition;
  175.   fseek(file, StartPosition + 4, SEEK_SET);
  176.   fwrite(&SaveSize, 4, 1, file);
  177.  
  178.   fseek(file, EndPosition, SEEK_SET);
  179. }
  180.  
  181.  
  182. // ********************************************
  183. // ************  AGS Interface  ***************
  184. // ********************************************
  185.  
  186.  
  187. void DrawScreenEffect(int sprite,int sprite_prev,int ide)
  188. {      
  189.         DrawEffect(sprite,sprite_prev,ide);
  190. }
  191.  
  192. void AGS_EngineStartup(IAGSEngine *lpEngine)
  193. {
  194.   engine = lpEngine;
  195.  
  196.   if (engine->version < 13)
  197.     engine->AbortGame("Engine interface is too old, need newer version of AGS.");
  198.  
  199.  
  200.   engine->RegisterScriptFunction("DrawScreenEffect", (void*)&DrawScreenEffect);
  201.  
  202.  
  203.  
  204.   engine->RequestEventHook(AGSE_PREGUIDRAW);
  205.   engine->RequestEventHook(AGSE_PRESCREENDRAW);
  206.  
  207. #if defined(PSP_VERSION) || defined(ANDROID_VERSION) || defined(IOS_VERSION)
  208.   engine->RequestEventHook(AGSE_SAVEGAME);
  209.   engine->RequestEventHook(AGSE_RESTOREGAME);
  210. #endif
  211. }
  212.  
  213. void AGS_EngineShutdown()
  214. {
  215.  
  216. }
  217.  
  218. int AGS_EngineOnEvent(int event, int data)
  219. {
  220.   if (event == AGSE_PREGUIDRAW)
  221.   {
  222.          // WindEffect(g_Fx,g_Fy,g_Trans,g_RW,g_RH);
  223.           /*
  224.     BITMAP* screen = engine->GetVirtualScreen();
  225.         BITMAP* ParticleGraph = engine->GetSpriteGraphic(4322);
  226.         //engine->BlitBitmap (100, 100, ParticleGraph, 0);
  227.         engine->BlitSpriteTranslucent(100, 100, ParticleGraph,50);
  228.         engine->ReleaseBitmapSurface(screen);
  229.         //engine->MarkRegionDirty(0,0,screen_width,screen_height);
  230.         engine->SetVirtualScreen(screen);*/
  231.   }
  232.   #if defined(PSP_VERSION) || defined(ANDROID_VERSION) || defined(IOS_VERSION)
  233.   else if (event == AGSE_RESTOREGAME)
  234.   {
  235.     RestoreGame((FILE*)data);
  236.   }
  237.   else if (event == AGSE_SAVEGAME)
  238.   {
  239.     SaveGame((FILE*)data);
  240.   }
  241. #endif
  242.   else if (event == AGSE_PRESCREENDRAW)
  243.   {
  244.     // Get screen size once here.
  245.     //engine->GetScreenDimensions(&screen_width, &screen_height, &screen_color_depth);
  246.         engine->UnrequestEventHook(AGSE_SAVEGAME);
  247.         engine->UnrequestEventHook(AGSE_RESTOREGAME);
  248.   }
  249.   return 0;
  250. }
  251.  
  252. int AGS_EngineDebugHook(const char *scriptName, int lineNum, int reserved)
  253. {
  254.   return 0;
  255. }
  256.  
  257. void AGS_EngineInitGfx(const char *driverID, void *data)
  258. {
  259. }
  260.  
  261.  
  262.  
  263. #if defined(WINDOWS_VERSION) && !defined(BUILTIN_PLUGINS)
  264.  
  265. // ********************************************
  266. // ***********  Editor Interface  *************
  267. // ********************************************
  268. //AGSFlashlight
  269. const char* scriptHeader =
  270.   "import void DrawScreenEffect(int sprite,int sprite_prev,int ide);\r\n";
  271.  
  272.  
  273. IAGSEditor* editor;
  274.  
  275.  
  276. LPCSTR AGS_GetPluginName(void)
  277. {
  278.   // Return the plugin description
  279.   return "AGSWave";
  280. }
  281.  
  282. int  AGS_EditorStartup(IAGSEditor* lpEditor)
  283. {
  284.   // User has checked the plugin to use it in their game
  285.  
  286.   // If it's an earlier version than what we need, abort.
  287.   if (lpEditor->version < 1)
  288.     return -1;
  289.  
  290.   editor = lpEditor;
  291.   editor->RegisterScriptHeader(scriptHeader);
  292.  
  293.   // Return 0 to indicate success
  294.   return 0;
  295. }
  296.  
  297. void AGS_EditorShutdown()
  298. {
  299.   // User has un-checked the plugin from their game
  300.   editor->UnregisterScriptHeader(scriptHeader);
  301. }
  302.  
  303. void AGS_EditorProperties(HWND parent)
  304. {
  305.   // User has chosen to view the Properties of the plugin
  306.   // We could load up an options dialog or something here instead
  307.   MessageBoxA(parent, "AGSWave", "About", MB_OK | MB_ICONINFORMATION);
  308. }
  309.  
  310. int AGS_EditorSaveGame(char* buffer, int bufsize)
  311. {
  312.   // We don't want to save any persistent data
  313.   return 0;
  314. }
  315.  
  316. void AGS_EditorLoadGame(char* buffer, int bufsize)
  317. {
  318.   // Nothing to load for this plugin
  319. }
  320.  
  321. #endif
  322.  
  323.  
  324. #if defined(BUILTIN_PLUGINS)
  325. } // namespace agswave
  326. #endif
  327.  
  328.  

I'm using 3.4.1 version of AGS
« Last Edit: 17 Feb 2019, 13:56 by Dualnames »
No more military army stuff. I'm alive and back.

Re: A custom plugin is throwing an error on Win 7
« Reply #1 on: 17 Feb 2019, 12:43 »
Are you sure it loads up correctly? You may turn logging on: "log=1" under  "[misc]" section in acsetup.cfg and get log in "%USERPROFILE%/Saved Games/.ags/"

So apparently 2/3rds of the Primordia squad, are using WINDOWS 7. I compiled a plugin recently, and I send the files over and they had two errors.
Error 1:
MSCVR100d.dll is missing

I can tell two things here, first of all MSCVR100 is a part of Visual C++ Redistributable , probably 2010.

Secondly, which also may be relevant, the letter "d" in the name indicates that you were building plugin in Debug configuration. Assuming you may have done same thing under MSVS 2008, this could be reason plugin still is not loaded correctly. Programs and libs built in Debug config require different set of system libraries. Double check that you are building in Release configuration when sending plugin to your testers/players.
« Last Edit: 17 Feb 2019, 12:45 by Crimson Wizard »

Snarky

  • Global Moderator
  • Private Insultant
    • Best Innovation Award Winner 2018, for his numerous additions to the AGS open source ecosystem including the new Awards Ceremony client and modules
    • Snarky worked on one or more games that won an AGS Award!
    •  
    • Snarky worked on one or more games that was nominated for an AGS Award!
Re: A custom plugin is throwing an error on Win 7
« Reply #2 on: 17 Feb 2019, 12:54 »
I had the first problem with my Clipboard plugin (compiled with MSVS 2017 on a Win10 system). I think fixing it involved playing with the "Runtime library" compiler flags (Project Properties | Configuration Properties | C/C++ | Code Generation). Not sure whether it's /MT or /MD (/MTd or /MDd for debug) that ended up working.

Dualnames

  • AGS Baker
  • Pretty Badass
    • Dualnames worked on one or more games that won an AGS Award!
    •  
    • Dualnames worked on one or more games that was nominated for an AGS Award!
Re: A custom plugin is throwing an error on Win 7
« Reply #3 on: 17 Feb 2019, 13:03 »
@CrimsonWizard:
The dll works fine on my windows 8 pc, with no issues whatsoever.

I set it to "Release" now. Also the Error 1 is fixed, it came up initially, but compiling it under Visual Studio 2008 fixed it. But Error 2 has been present since the start. Could it be a lack of a NET Framework?


@Snarky:
Multi-threaded DLL <- this is where it's set.
No more military army stuff. I'm alive and back.

Snarky

  • Global Moderator
  • Private Insultant
    • Best Innovation Award Winner 2018, for his numerous additions to the AGS open source ecosystem including the new Awards Ceremony client and modules
    • Snarky worked on one or more games that won an AGS Award!
    •  
    • Snarky worked on one or more games that was nominated for an AGS Award!
Re: A custom plugin is throwing an error on Win 7
« Reply #4 on: 17 Feb 2019, 13:12 »
Sorry, no clue about the second issue. The RegisterScriptHeader/Function calls look fine, and of course if it's working on your machine then there can't be something very wrong with the code itself.

I would be a bit nervous about the "compile on VS 2008" solution. As I understand the issue, it's that there's a version mismatch of the mscvr100.dll that the .dll was compiled against and the one present on the system running the game. Building on another version of VS may fix the problem for those particular users, but it would still potentially be there for someone else. The more robust solution is to ensure that the libraries it depends on are statically linked inside the .dll. So I think the setting should actually be set to "Multi-threaded (/MT)" rather than "Multi-threaded DLL (/MD)", even though it's a DLL you're building. (I could be wrong! I'm only half-remembering something I only half-understood in the first place. But at least, that's how it's set in my project.)
« Last Edit: 17 Feb 2019, 13:14 by Snarky »

Dualnames

  • AGS Baker
  • Pretty Badass
    • Dualnames worked on one or more games that won an AGS Award!
    •  
    • Dualnames worked on one or more games that was nominated for an AGS Award!
Re: A custom plugin is throwing an error on Win 7
« Reply #5 on: 17 Feb 2019, 13:15 »
The only reason it needed that dll was because I originally had it built it on VS 2010, I made a new project on VS 2008 and recompiled it, so it doesn't need the 2010s distributables, unfortunately the link error remains. Alright trying your other suggestion tho.

Edit: Same error.
« Last Edit: 17 Feb 2019, 13:19 by Dualnames »
No more military army stuff. I'm alive and back.

Re: A custom plugin is throwing an error on Win 7
« Reply #6 on: 17 Feb 2019, 13:21 »
Dualnames, have you tried checking the log?

The only reason it needed that dll was because I originally had it built it on VS 2010, I made a new project on VS 2008 and recompiled it, so it doesn't need the 2010s distributables

But it will still need 2008 redistributables. So building with /MT switch may make sense.
We are building AGS engine with /MT switch to prevent these problems.

EDIT: ok, I will try testing your plugin in a dummy game.
« Last Edit: 17 Feb 2019, 13:24 by Crimson Wizard »

Dualnames

  • AGS Baker
  • Pretty Badass
    • Dualnames worked on one or more games that won an AGS Award!
    •  
    • Dualnames worked on one or more games that was nominated for an AGS Award!
Re: A custom plugin is throwing an error on Win 7
« Reply #7 on: 17 Feb 2019, 13:24 »
I did set it to MT and it returned the same error. I will ask, it's not on my computer, so I'm talking with the artist, and trying to figure out stuff.

Working on getting that log for you.
« Last Edit: 17 Feb 2019, 13:27 by Dualnames »
No more military army stuff. I'm alive and back.

Re: A custom plugin is throwing an error on Win 7
« Reply #8 on: 17 Feb 2019, 13:33 »
Hmm, well, it worked for me, but I have Visual Studio installed so that makes a difference usually in terms of dependencies.
The plugin you linked in the first post requires MSVCR90D.dll, which is a debug library (will probably be missing on most player's PCs).

Anyway, I managed to start the test game without problems, however it crashed when calling DrawScreenEffect.

Dualnames

  • AGS Baker
  • Pretty Badass
    • Dualnames worked on one or more games that won an AGS Award!
    •  
    • Dualnames worked on one or more games that was nominated for an AGS Award!
Re: A custom plugin is throwing an error on Win 7
« Reply #9 on: 17 Feb 2019, 13:38 »
Adventure Game Studio v3.4 Interpreter
Copyright (c) 1999-2011 Chris Jones and 2011-2018 others
ACI version 3.4.1.15

Installing exception handler
Initializing allegro
Initializing game data
Looking for the game data file
Located game data file: d:/THEWRE~1/NEWBUI~1/14/STRANG~1.EXE
Opened game data file: game28.dta
Game data version: 49
Compiled with: 3.4.1.15
Setting up game configuration
Setting up window
Initializing TTF renderer
Initializing mouse: number of buttons reported is 8
Checking memory
Data directory: d:/THEWRE~1/NEWBUI~1/14
Initializing audio vox
Audio vox found and initialized.
Initializing keyboard
Install timer
Initialize sound drivers
Sound settings: digital driver ID: 'AXA ' (0x41584120), MIDI driver ID: 'Auto' (0xffffffff)
Installed digital driver ID: 'AXA ' (0x41584120), MIDI driver ID: 'W32M' (0x5733324d)
Install exit handler
Initialize path finder library
Load game data
Game GUI version: 118
Requested script API: v3.4.1 (5), compat level: v3.4.0 (4)
Built library path: agswaves.dll
Plugin loading failed, trying built-in plugins...
No built-in plugin found. Plugin loading failed!
No placeholder functions for the plugin 'agswaves' found. The game might fail to load.
No more military army stuff. I'm alive and back.

Dualnames

  • AGS Baker
  • Pretty Badass
    • Dualnames worked on one or more games that won an AGS Award!
    •  
    • Dualnames worked on one or more games that was nominated for an AGS Award!
Re: A custom plugin is throwing an error on Win 7
« Reply #10 on: 17 Feb 2019, 13:39 »
http://primordia-game.com/Files0/Strangelando/agswavev5.rar

This is the 'proper' version of it (compiled with VS 2008) and the one we tested for the log above
« Last Edit: 17 Feb 2019, 13:44 by Dualnames »
No more military army stuff. I'm alive and back.

Dualnames

  • AGS Baker
  • Pretty Badass
    • Dualnames worked on one or more games that won an AGS Award!
    •  
    • Dualnames worked on one or more games that was nominated for an AGS Award!
Re: A custom plugin is throwing an error on Win 7
« Reply #11 on: 17 Feb 2019, 13:46 »
We got it working boys <3

edit: So what I changed was setting it to /MT (i sent the wrong file to the guy testing it) and all is well.
No more military army stuff. I'm alive and back.

Re: A custom plugin is throwing an error on Win 7
« Reply #12 on: 17 Feb 2019, 13:49 »
We got it working boys <3

edit: So what I changed was setting it to /MT (i sent the wrong file to the guy testing it) and all is well.

Ok, that explains ).

Dualnames

  • AGS Baker
  • Pretty Badass
    • Dualnames worked on one or more games that won an AGS Award!
    •  
    • Dualnames worked on one or more games that was nominated for an AGS Award!
Re: A custom plugin is throwing an error on Win 7
« Reply #13 on: 17 Feb 2019, 13:55 »
So setting to /MT where Snarky explained, and getting it compiled under VS2008 solved both issues, marking this as solved. I feel really bad cause each time you suggest one thing first post, we do like 10 posts of dicking around, was the first post all along <3
No more military army stuff. I'm alive and back.

Re: A custom plugin is throwing an error on Win 7 [SOLVED]
« Reply #14 on: 17 Feb 2019, 13:59 »
Note that if you build with /MT you may probably use whatever MSVS as well, 2010, 2017.

Snarky

  • Global Moderator
  • Private Insultant
    • Best Innovation Award Winner 2018, for his numerous additions to the AGS open source ecosystem including the new Awards Ceremony client and modules
    • Snarky worked on one or more games that won an AGS Award!
    •  
    • Snarky worked on one or more games that was nominated for an AGS Award!
Re: A custom plugin is throwing an error on Win 7 [SOLVED]
« Reply #15 on: 17 Feb 2019, 20:44 »
I feel really bad cause each time you suggest one thing first post, we do like 10 posts of dicking around, was the first post all along <3

Don't. I feel like when we get into these heavier technical issues, my guesses or advice is wrong more often than not, so I'm just happy it panned out this time around.