Skip to content

GetFirstArea function not compiling

Greetings,
I am updating my 1.69 server to EE, and have gotten the following when compiling the scripts- GetFirstArea, GetNextArea already implemented even though there is only one line with the object GetFirstArea() and object GetNextArea() any ideas on how to fix this?
thanks!

Comments

  • squattingmonksquattingmonk Member Posts: 59
    Can you post your script?
  • mlkent22mlkent22 Member Posts: 41
    //::///////////////////////////////////////////////
    //:: Area Include File
    //:: area_inc
    //:: Copyright (c) 2001 Bioware Corp.
    //:://////////////////////////////////////////////
    /*
    functions.
    Used in conjunction with the Area Place Holder
    placeable. If you want your area to show up in
    the list of areas, you must include this placeable
    somewhere in your area.
    */


    // Area Size Constants
    const int MaxAreaSizeX = 32;
    const int MaxAreaSizeY = 32;

    string AREA_DESIGNATOR_TAG = "area_designator";

    const string AREA_LIST_PREFIX = "AREA_";
    const string AREA_LIST_COUNT = "AREA_COUNT";
    const string AREA_LIST_POINTER = "AREA_LIST_POINTER";

    //------------------------------------------------------------------------------
    // Initialize the modules list of areas.
    //------------------------------------------------------------------------------
    void InitializeAreaList()
    {
    int nNth = 0;
    object oDesignator = GetObjectByTag(AREA_DESIGNATOR_TAG,nNth);
    object oModule = GetModule();
    object oArea;

    while (GetIsObjectValid(oDesignator))
    {
    oArea = GetArea(oDesignator);
    SetLocalObject(oModule, AREA_LIST_PREFIX+IntToString(nNth), oArea);
    SetPlotFlag(oDesignator,FALSE);
    DestroyObject(oDesignator);
    nNth++;
    oDesignator = GetObjectByTag(AREA_DESIGNATOR_TAG,nNth);
    }
    SetLocalInt(oModule,AREA_LIST_COUNT,(nNth));
    }

    //------------------------------------------------------------------------------
    // Provides direct access to area nIdx in the modules area list
    //------------------------------------------------------------------------------
    object GetAreaByIndex(int nIdx)
    {
    object oRet = GetLocalObject(GetModule(), AREA_LIST_PREFIX+IntToString(nIdx));
    return oRet;
    }
    //------------------------------------------------------------------------------
    // Return the First Area in the Modules Arealist
    //------------------------------------------------------------------------------
    object GetFirstArea()
    {
    SetLocalInt (GetModule(), AREA_LIST_POINTER,0);
    object oRet = GetAreaByIndex(0);
    return oRet;
    }
    //------------------------------------------------------------------------------
    // Return the Next Area in the Modules Arealist
    //------------------------------------------------------------------------------
    object GetNextArea()
    {
    int nIdx = GetLocalInt (GetModule(),AREA_LIST_POINTER);
    nIdx++;
    object oRet = GetAreaByIndex(nIdx);
    SetLocalInt (GetModule(),AREA_LIST_POINTER,nIdx);
    return oRet;
    }
    //------------------------------------------------------------------------------
    // Return the number of areas in the module
    //------------------------------------------------------------------------------
    int GetAreaCount()
    {
    int nRet = GetLocalInt(GetModule(),AREA_LIST_COUNT);
    return nRet;
    }

    //------------------------------------------------------------------------------
    // Returns a random location within the specified area.
    //------------------------------------------------------------------------------
    location AreaRandomLocation(object oArea)
    {
    location lLoc;
    int nRanX, nRanY, nRanZ;

    nRanX = Random(MaxAreaSizeX);
    nRanY = Random(MaxAreaSizeY);
    nRanZ = 0; // Random(MaxAreaSizeZ); ???

    float fX = IntToFloat(nRanX);
    float fY = IntToFloat(nRanY);
    float fZ = IntToFloat(nRanZ);

    vector vVec = Vector(fX, fY, fZ);
    lLoc = Location(oArea, vVec, 0.0);
    return lLoc;
    }
  • squattingmonksquattingmonk Member Posts: 59
    edited April 2018
    You're defining GetFirstArea() and GetNextArea() on lines 58 and 67, respectively. Since functions with those names have been added to the base game, this won't compile anymore. The solution is to remove these function definitions. In fact, this area placeholder system is probably obsolete (minus AreaRandomLocation(), which seems to be unrelated to the rest).

    While it's a handy idea to have a list of areas that could be accessed by index, the fact that areas can be destroyed now means that index could change and no longer be valid. If you're okay with this and willing to restrict creating and destroying areas to wrapper functions, you could probably replace this script with the following:

    // ----------------------------------------------------------------------------- // Constants // ----------------------------------------------------------------------------- const string AREA_INDEX = "AREA_INDEX"; // ----------------------------------------------------------------------------- // Function Implementation // ----------------------------------------------------------------------------- // Returns a count of all areas in the module. int CountAreas() { object oModule = GetModule(); // Count the number of areas indexed. int nCount = GetLocalInt(oModule, AREA_INDEX); // If the count has not been created, initializxe the index if (!nCount) { object oArea = GetFirstArea(); while (GetIsObjectValid(oArea)) { SetLocalObject(oModule, AREA_INDEX + IntToString(nCount), oArea); SetLocalInt(oArea, AREA_INDEX, nCount++); oArea = GetNextArea(); } SetLocalInt(oModule, AREA_INDEX, nCount); } return nCount; } // Returns the area at nIndex. Note the this index beings at 0. object GetAreaByIndex(int nIndex) { CountAreas(); return GetLocalObject(GetModule(), AREA_INDEX + IntToString(nIndex)); } // Returns the index of oArea. Note that this index beings at 0. int GetAreaIndex(object oArea) { CountAreas(); return GetLocalInt(oArea, AREA_INDEX); } // Destroys the area at nIndex, preserving the relative order of remaining // entries if bPreserveOrder is TRUE. Returns the new area count. int DestroyAreaByIndex(int nIndex, int bPreserveOrder = FALSE) { int nCount = CountAreas(); // Sanity check if (nIndex < 0 || nIndex >= nCount) return nCount; object oModule = GetModule(); object oArea = GetLocalObject(oModule, AREA_INDEX + IntToString(nIndex)); DestroyArea(oArea); if (bPreserveOrder) { // Loop through all objects in the index and update their positions for (nIndex; nIndex < nCount; nIndex++) { oArea = GetLocalObject(oModule, AREA_INDEX + IntToString(nIndex + 1)); SetLocalObject(oModule, AREA_INDEX + IntToString(nIndex), oArea); // Update the area's listing of its own index SetLocalInt(oArea, AREA_INDEX, nIndex); } } else { // Swap the last area into position oArea = GetLocalObject(oModule, AREA_INDEX + IntToString(nCount)); SetLocalObject(oModule, AREA_INDEX + IntToString(nIndex), oArea); // Update the area's listing of its own index SetLocalInt(oArea, AREA_INDEX, nIndex); } // Set the new count SetLocalInt(oModule, AREA_INDEX, --nCount); // Blank the last area DeleteLocalObject(oModule, AREA_INDEX + IntToString(nCount)); return nCount; } // Destroys an area and updates the index, preserving the relative order of the // index if bPreserveOrder is TRUE. Returns the new area count. int DestroyAreaByValue(object oArea, int bPreserveOrder = FALSE) { int nIndex = GetAreaIndex(oArea); return DestroyAreaByIndex(nIndex, bPreserveOrder); } // Adds an area to the index. Returns the new area count. Use when adding or // copying an area. int IndexArea(object oArea) { int nCount = CountAreas(); SetLocalInt(oArea, AREA_INDEX, nCount); object oModule = GetModule(); SetLocalObject(oModule, AREA_INDEX + IntToString(nCount), oArea); SetLocalInt(oModule, AREA_INDEX, ++nCount); return nCount; }
    Post edited by squattingmonk on
Sign In or Register to comment.