| Home Page | Recent Changes | Preferences

Setting Up VCPlusPlus/The CPP File

In your C file, include the following:

# both from the unreal public sources
#include "core.h"
#include "engine.h"

# the include that was generated by ucc
#include "$UNREALDIR\SQLite\Inc\SQLiteClasses.h"

Strangely enough, the macro IMPLEMENT_PACKAGE doesn't do what it's supposed to do. Instead, add the following line next: (replacing HCSQLIB with the name of your package)

extern "C" DLL_EXPORT TCHAR GPackage[];
DLL_EXPORT TCHAR GPackage[] = TEXT("HCSQLIB");

Then, tell unreal which class(es) this file is implementing. Use

IMPLEMENT_CLASS(ASQLITEFile);

Third, tell unreal which functions you're implementing:

Replace PACKAGE with the name of your package, ID with a UNIQUE number for static functions, or -1 for non-static functions. FUNCTION is the name of your function, prefixed with exec.

IMPLEMENT_FUNCTION(PACKAGE, ID, FUNCTION);

Next, since you didn't use IMPLEMENT_PACKAGE (which doesn't work), you'll have to define your own DLL entry point yourself.

BOOL __stdcall DllMain(HINSTANCE hInInstance, DWORD dwCallType, LPVOID lpPretendIDontExist)
{
  if(dwCallType == DLL_PROCESS_ATTACH)
  {
    // initialize your dll
    hInstance = hInInstance;
  }
  else if(dwCallType == DLL_PROCESS_DETACH)
  {
    // do some cleanup
  }
  return TRUE;

Finally, your function:

Note that the parameters are the same for all functions, no matter what parameters are defined in the corresponding .uc file. See the [native coding reference]? for more information about how to obtain parameters. Also note that the variables s1, i1 and i2 are defined by the macros P_GET_STR and P_GET_INT automatically. The guard and unguardexec macros actually create a try..catch block.

This function takes a string and two integers as parameters and returns the product of the two integers.

void
MyPackage::execTest(FFrame& Stack, RESULT_DECL)
{
  guard(MyPackage::execTest);
  P_GET_STR(s1);
  P_GET_INT(i1);
  P_GET_INT(i2);
  P_FINISH;

  (*(DWORD*)Result) = i1 * i2;

  unguardexec;


}

The according unrealscript function would look like this:

native function int Test(string sStringThatIsIgnored, int iFactor1, int iFactor2);

The Unreal Engine Documentation Site

Wiki Community

Topic Categories

Image Uploads

Random Page

Recent Changes

Offline Wiki

Unreal Engine

Console Commands

Terminology

FAQs

Help Desk

Mapping Topics

Mapping Lessons

UnrealEd Interface

UnrealScript Topics

UnrealScript Lessons

Making Mods

Class Tree

Modeling Topics

Chongqing Page

Log In