Ejemplo n.º 1
0
CString CLogin::GetHome()
{
	int len;

	const char* domain = GetZone();
	const char* name = GetMyName();

	m_szHome = "/" + GetZone() + "/home/" + GetMyName();

	return m_szHome;
}
extern void main(void)
{
    OSStatus err;
    FCBPBRec fcbPB;
    FSSpec fss;

    // 1. Show our "icon march" icon
    ShowInitIcon(128, true);

    // 2. Find our FSSpec
    fss.name[0] = 0;
    fcbPB.ioNamePtr = fss.name;
    fcbPB.ioVRefNum = 0;
    fcbPB.ioRefNum = (short)CurResFile();
    fcbPB.ioFCBIndx = 0;
    err = PBGetFCBInfoSync(&fcbPB);

    // 3. Tell CFM that we're a CFM library container file
    fss.vRefNum = fcbPB.ioFCBVRefNum;
    fss.parID = fcbPB.ioFCBParID;
    if (err == noErr) err = FragRegisterFileLibs(&fss, false);

    // 4. Now that CFM knows we're a library container, tell it to go and get our library
    if (err == noErr)
    {
        CFragConnectionID c;
        Ptr m;
        Str255 e;
        THz oldZone = GetZone();
        SetZone(SystemZone());
        err = GetSharedLibrary("\pDarwin;mDNS", kPowerPCCFragArch, kLoadCFrag, &c, &m, e);
        SetZone(oldZone);
    }
Ejemplo n.º 3
0
GYINT32 GYScene::RemoveCreature(GYCreature& creature)
{
	GYINT32 result = INVALID_VALUE;
	do 
	{
		GYZone* pZone = GetZone(creature.GetPosition());
		if (GYNULL == pZone)
		{
			break;
		}

		creature.OnLeaveScene(*this);

		if (0 != pZone->RemoveCreature(creature))
		{
			break;
		}

		if (0 !=  m_creatureSet[creature.GetObjectType()].Delete(creature))
		{
			break;
		}

		result = 0;

	} while (GYFALSE);
	return result;
}
Ejemplo n.º 4
0
pascal short
QueryServices(queryInfoPtr query_info, char async)
{
    SAPpb		pb;

    /*
     * Valid query?
     */
    if (query_info == (queryInfoPtr)0) {
        return (SAP_INVALID_ARG);
    }
    if ((query_info->queryType != GENERAL_SERVICE_QUERY) && (query_info->queryType != NEAREST_SERVICE_QUERY)) {
        return (SAP_INVALID_ARG);
    }

    if ((query_info->serviceType == 0xFFFF) && (query_info->queryType != GENERAL_SERVICE_QUERY)) {
        return (SAP_INVALID_ARG);
    }

    query_info->sap_entries = (SAP_RESPONSE_LIST_ENTRY *)0;

    pb.csCode = QUERYSERVICES;
    pb.csParams.query_service.query_info = query_info;
    pb.csParams.query_service.async = async;
    pb.csParams.query_service.appZone = GetZone();
#if !defined(powerc) && !defined (__powerc)
    pb.csParams.query_service.appA5 = IpxGetRegisterA5();
#endif

    /*
     * Make a synchronous call to the driver.  An async QueryServices is
     * handled by the driver rather than by the Mac OS.
     */
    return (call_sap(&pb));
}
Ejemplo n.º 5
0
GYINT32 GYScene::AddCreature(GYCreature& creature, const GYPosition& position)
{
	GYINT32 result = INVALID_VALUE;
	do 
	{
		GYZone* pZone = GetZone(position);
		if (GYNULL == pZone)
		{
			break;
		}

		if (GYTRUE != m_creatureSet[creature.GetObjectType()].Add(creature))
		{
			break;
		}

		if (0 != pZone->AddCreature(creature))
		{
			m_creatureSet[creature.GetObjectType()].Delete(creature);
			break;
		}
		creature.SetPosition(position);
		creature.OnEnterScene(*this);
		result = 0;

	} while (GYFALSE);
	return result;
}
void StarSystem::AddUnit( Unit *unit )
{
    if ( stats.system_faction == FactionUtil::GetNeutralFaction() )
        stats.CheckVitals( this );
    if (unit->specInterdiction > 0 || unit->isPlanet() || unit->isJumppoint() || unit->isUnit() == ASTEROIDPTR) {
        Unit *un;
        bool  found = false;
        for (un_iter i = gravitationalUnits().createIterator();
             (un = *i) != NULL;
             ++i)
            if (un == unit) {
                found = true;
                break;
            }
        if (!found)
            gravitationalUnits().prepend( unit );
    }
    drawList.prepend( unit );
    unit->activeStarSystem = this;     //otherwise set at next physics frame...
    UnitFactory::broadcastUnit( unit, GetZone() );
    unsigned int priority = UnitUtil::getPhysicsPriority( unit );
    //Do we need the +1 here or not - need to look at when current_sim_location is changed relative to this function
    //and relative to this function, when the bucket is processed...
    unsigned int tmp = 1+( (unsigned int) vsrandom.genrand_int32() )%priority;
    this->physics_buffer[(this->current_sim_location+tmp)%SIM_QUEUE_SIZE].prepend( unit );
    stats.AddUnit( unit );
}
Ejemplo n.º 7
0
static int
MacintoshInit()
{
    THz theZone = GetZone();
    SysEnvRec   sys;

    
    /*
     * There is a bug in systems earlier that 7.5.5, where a second BOA will
     * get a corrupted heap.  This is the fix from TechNote 1070
     */
     
    SysEnvirons(1, &sys);

    if (sys.systemVersion < 0x0755)
    {
        if ( LMGetHeapEnd() != theZone->bkLim) {
            LMSetHeapEnd(theZone->bkLim);
        }
    }
    
#if GENERATING68K && !GENERATINGCFM
    SetApplLimit(GetApplLimit() - (TCL_MAC_68K_STACK_GROWTH));
#endif
    MaxApplZone();

    InitGraf((Ptr)&qd.thePort);
    		    
    /* No problems with initialization */
    Tcl_MacSetEventProc(HandleHighLevelEvents);

    return TCL_OK;
}
Ejemplo n.º 8
0
static THz SetSystemZone(void)
	// Sets the current zone to the system zone, returning
	// the previous value.
{
	THz result;
	
	result = GetZone();
	SetZone(SystemZone());
	return result;
}
Ejemplo n.º 9
0
OSErr TotalHack(CFragConnectionID connID)
{
	Handle				theStrings;
	CMBufferSizes		bufSizes;
	short					procID;
	Str255				toolName;
	OSErr					error;
	FSSpec				where;
	short					ref;
	char*					end;
	Ptr					tempString;
	char*					here;
	short					baud;
	Boolean				prefsChanged = false;
	THz					myZone;
	ser_t*				storage;
	gConnection = nil;

	// get a Connection Tool name
	strcpy((char *)toolName, "Apple Modem Tool");						// so try to use the Apple modem tool
	c2pstr((char *)toolName);
	end = (char *)(toolName + toolName[0] + 1);
	memset(end, '\0', 255 - toolName[0]);
	// init the CMBufferSizes variable so that Tool will init with defaults

	bufSizes[cmDataIn] = 0;
	bufSizes[cmDataOut] = 0;
	bufSizes[cmCntlIn] = 0;
	bufSizes[cmCntlOut] = 0;
	bufSizes[cmAttnIn] = 0;
	bufSizes[cmAttnOut] = 0;
	bufSizes[cmRsrvIn] = 0;
	bufSizes[cmRsrvOut] = 0;

	error = noErr;
	myZone = GetZone();
	SetZone(SystemZone());
	// get a process ID for the tool
	procID = CMGetProcID(toolName);
	if (procID == -1) {
		error = -2;
	}

	// now get a conn record set up
	if (error == noErr) {
		gConnection = CMNew(procID, cmData|cmNoMenus|cmQuiet, bufSizes, 0, 0);
		if (gConnection != nil) {
			storage = (ser_t*)NewPtrClear(sizeof(ser_t));
			storage->sConnection = gConnection;
			error = SetData(connID, (unsigned long)storage);
		}
	}

	return error;
}
Ejemplo n.º 10
0
GYVOID GYScene::OnCreatureChangePosition(GYCreature& creature, const GYPosition& beforChange, const GYPosition& afterChange)
{
	GYZone* pBeforZone = GetZone(beforChange);
	GYZone* pAfterZone = GetZone(afterChange);
	if (pBeforZone == pAfterZone)
	{
		return;
	}

	_GetSyncRange(pBeforZone, pAfterZone, m_sceneConfig->SysnRange, m_oldSyncZoneID, m_newSyncZoneID);

	//1 通知在pBeforZone同步范围内,不在pAfterZone同步范围内的玩家
	//删除该creature

	//2 通知不在pBeforZone同步范围内,在pAfterZone同步范围内的玩家
	//添加该creature

	//3 如果该creature是玩家,通知该玩家删除在pBeforZone同步范围内,不在pAfterZone同步范围内的creature

	//4 如果该creature是玩家,通知该玩家添加不在pBeforZone同步范围内,在pAfterZone同步范围内的creature

}
Ejemplo n.º 11
0
boolean menewmenubar (hdloutlinerecord houtline, hdlmenubarstack *hstack) {
	
	/*
	create a new, empty menubar data structure, linked into menubarlist.

	4.1b2 dmb: xxx - create stack in the (client) application zone
	*/
	
	register hdlmenubarstack hs;
	
	#if 0
	
		THz savezone = GetZone ();
		
		SetZone (ApplicationZone ());
		
		*hstack = (hdlmenubarstack) NewHandleClear (sizeof (tymenubarstack));
		
		SetZone (savezone);
		
		hs = *hstack; /*move into register*/
		
		if (hs == nil) {
		
			memoryerror ();
			
			return (false);
			}
		
	#else
		
		if (!newclearhandle (sizeof (tymenubarstack), (Handle *) hstack))
			return (false);
	
		hs = *hstack; /*move into register*/
		
	#endif
	
	(**hs).menubaroutline = houtline;
	
	(**hs).ixdeletedmenu = -1; /*no halfway deleted menu*/
	
	/*
	if (pushmenubarlist (hs)) /%add it to the end of our list%/
		
		(**hs).flactive = (**menubarlist).flactive;
	*/
	
	return (true);
	} /*menewmenubar*/
Ejemplo n.º 12
0
/// Retrieve a dominance zone by closest city
CvTacticalDominanceZone* CvTacticalAnalysisMap::GetZoneByCity(CvCity* pCity, bool bWater)
{
	CvTacticalDominanceZone* pZone;
	for(int iI = 0; iI < GetNumZones(); iI++)
	{
		pZone = GetZone(iI);
		if(pZone->GetClosestCity() == pCity && pZone->IsWater() == bWater)
		{
			return pZone;
		}
	}

	return NULL;
}
Ejemplo n.º 13
0
pascal OSErr mDNS_CFMInit(const CFragInitBlock *theInitBlock)
{
    extern pascal OSErr __initialize(const CFragInitBlock *theInitBlock);
    __initialize(theInitBlock); // MUST do this first!
    {
        mStatus err;
        THz oldZone = GetZone();
        SetZone(SystemZone());
        LogMsg("mDNS/DNS-SD with Macsbug breaks -- do not ship this version to customers");
        err = mDNS_Init(&mDNSStorage, &PlatformSupportStorage, rrcachestorage, RR_CACHE_SIZE,
                        mDNS_Init_AdvertiseLocalAddresses, mDNS_StatusCallback, mDNS_Init_NoInitCallbackContext);
        SetZone(oldZone);
        return((OSErr)err);
    }
}
	__int64 CTimeZones::GetDelta(CTRef TRef, const CGeoPoint& pt)
	{
		__int64 delta = __int64(pt.m_lon / 15 * 3600);

		cctz::time_zone zone;
		if (GetZone(pt, zone))
		{
			const auto tp = cctz::convert(cctz::civil_second(TRef.GetYear(), int(TRef.GetMonth() + 1), int(TRef.GetDay() + 1), int(TRef.GetHour()), 0, 0), zone);
			const cctz::time_zone::absolute_lookup al = zone.lookup(tp);
			delta = al.offset;
		}

			//	{
			//		std::string str_zone = record[7];
			//		delta = WBSF::ToInt(str_zone);
			//		ASSERT(delta >= -12 && delta<=12);
			//	}


		//int poly = -1;
		//if (TIME_ZONE.IsInside(pt, &poly))
		//{
		//	const CDBF3& DBF = TIME_ZONE.GetDBF();
		//	const CDBFRecord& record = DBF[poly];
		//	ASSERT(record.size() >= 14);
		//	std::string str_zone = record[13];

		//	cctz::time_zone zone;
		//	if (!str_zone.empty() && cctz::load_time_zone(str_zone, &zone))
		//	{
		//		
		//		const auto tp = cctz::convert(cctz::civil_second(TRef.GetYear(), int(TRef.GetMonth() + 1), int(TRef.GetDay() + 1), int(TRef.GetHour()), 0, 0), zone);
		//		const cctz::time_zone::absolute_lookup al = zone.lookup(tp);

		//		__int64 delta_s = al.offset;
		//		delta = Round(delta_s / 3600);
		//	}
		//	else
		//	{
		//		std::string str_zone = record[7];
		//		delta = WBSF::ToInt(str_zone);
		//		ASSERT(delta >= -12 && delta<=12);
		//	}
		//}

		return delta;
	}
Ejemplo n.º 15
0
// Is this plot in dangerous territory?
bool CvTacticalAnalysisMap::IsInEnemyDominatedZone(CvPlot* pPlot)
{
	CvTacticalAnalysisCell* pCell;
	int iPlotIndex;
	CvTacticalDominanceZone* pZone;

	iPlotIndex = GC.getMap().plotNum(pPlot->getX(), pPlot->getY());
	pCell = GetCell(iPlotIndex);

	for(int iI = 0; iI < GetNumZones(); iI++)
	{
		pZone = GetZone(iI);
		if(pZone->GetDominanceZoneID() == pCell->GetDominanceZone())
		{
			return (pZone->GetDominanceFlag() == TACTICAL_DOMINANCE_ENEMY);
		}
	}

	return false;
}
	__int64 CTimeZones::GetDelta(__int64 time, const CGeoPoint& pt)
	{
		__int64 delta = __int64(pt.m_lon / 15 * 3600);
		cctz::time_zone zone;
		if (GetZone(pt, zone))
		{
			const auto tp = std::chrono::system_clock::from_time_t(time);
			const cctz::time_zone::absolute_lookup al = zone.lookup(tp);

			delta = al.offset;
		}

		/*int poly = -1;
		if (TIME_ZONE.IsInside(pt, &poly))
		{
			const CDBF3& DBF = TIME_ZONE.GetDBF();
			const CDBFRecord& record = DBF[poly];
			ASSERT(record.size() >= 14);
			std::string str_zone = record[13];


			cctz::time_zone zone;
			if (!str_zone.empty() && cctz::load_time_zone(str_zone, &zone, delta))
			{
				const auto tp = std::chrono::system_clock::from_time_t(time);
				const cctz::time_zone::absolute_lookup al = zone.lookup(tp);

				delta = al.offset;
			}
			else
			{
				std::string str_zone = record[7];
				delta = WBSF::ToInt(str_zone);
				ASSERT(delta >= -12 && delta <= 12);
			}
		}*/

		return delta;
	}
Ejemplo n.º 17
0
void LoadZoneList()
{
	g_PTrigger = new CNpcEntity();	// нужно в конструкторе CNpcEntity задавать модель по умолчанию

	for (uint16 ZoneID = 0; ZoneID < MAX_ZONEID; ZoneID++)
	{
        CZone* PZone = new CZone((ZONEID)ZoneID, GetCurrentRegion(ZoneID), GetCurrentContinent(ZoneID));
        g_PZoneList[ZoneID] = PZone;
    }

	LoadNPCList();
	LoadMOBList();

    for (uint16 ZoneID = 0; ZoneID < MAX_ZONEID; ZoneID++)
    {
        CZone* PZone = GetZone(ZoneID);
		PZone->ZoneServer(-1);
		
		if (PZone->GetIP() != 0)
			luautils::OnZoneInitialise(PZone->GetID());
	}
    UpdateWeather();
}
Ejemplo n.º 18
0
void fastPoll( void )
	{
	RANDOM_STATE randomState;
	BYTE buffer[ RANDOM_BUFSIZE + 8 ];
/*	BatteryTimeRec batteryTimeInfo; */
	SMStatus soundStatus;
	ThreadID threadID;
	ThreadState threadState;
	EventRecord eventRecord;
	Point point;
	WindowPtr windowPtr;
	PScrapStuff scrapInfo;
	UnsignedWide usSinceStartup;
	BYTE dataBuffer[ 2 + 8 ];
/*	short driverRefNum; */
	UInt32 dateTime;
/*	int count, dummy; */
	NumVersion version;

	initRandomData( randomState, buffer, RANDOM_BUFSIZE );

	/* Get the status of the last alert, how much battery time is remaining
	   and the voltage from all batteries, the internal battery status, the
	   current date and time and time since system startup in ticks, the
	   application heap limit and current and heap zone, free memory in the
	   current and system heap, microseconds since system startup, whether
	   QuickDraw has finished drawing, modem status, SCSI status
	   information, maximum block allocatable without compacting, available
	   stack space, the last QuickDraw error code */
/*	addRandomValue( randomState, GetAlertStage() );
	count = BatteryCount();
	while( count-- > 0 )
		{
		addRandomValue( randomState,
				   GetBatteryVoltage( count ) );
		GetBatteryTimes( count, &batteryTimeInfo );
		addRandomData( randomState, &batteryTimeInfo,
					   sizeof( BatteryTimeRec ) );
		}
	if( !BatteryStatus( buffer, dataBuffer + 1 ) )
		addRandomValue( randomState, dataBuffer );
*/	GetDateTime( &dateTime );
	addRandomValue( randomState, dateTime );
	addRandomValue( randomState, TickCount() );
#if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON
	addRandomValue( randomState, GetApplLimit() );
	addRandomValue( randomState, GetZone() );
	addRandomValue( randomState, SystemZone() );
	addRandomValue( randomState, FreeMem() );
	addRandomValue( randomState, FreeMemSys() );
#endif
/*	MicroSeconds( &usSinceStartup );
	addRandomData( randomState, &usSinceStartup, sizeof( UnsignedWide ) ); */
	addRandomValue( randomState, QDDone( NULL ) );
/*	ModemStatus( dataBuffer );
	addRandomValue( randomState, dataBuffer[ 0 ] ); */
#if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON
	addRandomValue( randomState, SCSIStat() );
#endif
	addRandomValue( randomState, MaxBlock() );
	addRandomValue( randomState, StackSpace() );
	addRandomValue( randomState, QDError() );

	/* Get the event code and message, time, and mouse location for the next
	   event in the event queue and the OS event queue */
	if( EventAvail( everyEvent, &eventRecord ) )
		addRandomData( randomState, &eventRecord, sizeof( EventRecord ) );
#if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON
	if( OSEventAvail( everyEvent, &eventRecord ) )
		addRandomData( randomState, &eventRecord, sizeof( EventRecord ) );
#endif

	/* Get all sorts of information such as device-specific info, grafport
	   information, visible and clipping region, pattern, pen, text, and
	   colour information, and other details, on the topmost window.  Also
	   get the window variant.  If there's a colour table record, add the
	   colour table as well */
	if( ( windowPtr = FrontWindow() ) != NULL )
		{
/*		CTabHandle colourHandle; */

#if !defined OPAQUE_TOOLBOX_STRUCTS || !OPAQUE_TOOLBOX_STRUCTS
		addRandomData( randomState, windowPtr, sizeof( GrafPort ) );
#endif
		addRandomValue( randomState, GetWVariant( windowPtr ) );
/*		if( GetAuxWin( windowPtr, colourHandle ) )
			{
			CTabPtr colourPtr;

			HLock( colourHandle );
			colourPtr = *colourHandle;
			addRandomData( randomState, colourPtr, sizeof( ColorTable ) );
			HUnlock( colourHandle );
			} */
		}

	/* Get mouse-related such as the mouse button status and mouse position,
	   information on the window underneath the mouse */
	addRandomValue( randomState, Button() );
	GetMouse( &point );
	addRandomData( randomState, &point, sizeof( Point ) );
	FindWindow( point, &windowPtr );
#if !defined OPAQUE_TOOLBOX_STRUCTS || !OPAQUE_TOOLBOX_STRUCTS
	if( windowPtr != NULL )
		addRandomData( randomState, windowPtr, sizeof( GrafPort ) );
#endif

	/* Get the size, handle, and location of the desk scrap/clipboard */
#if !defined CALL_NOT_IN_CARBON || CALL_NOT_IN_CARBON
	scrapInfo = InfoScrap();
	addRandomData( randomState, scrapInfo, sizeof( ScrapStuff ) );
#endif

	/* Get information on the current thread */
	threadID = kCurrentThreadID; /*GetThreadID( &threadID ); */
	GetThreadState( threadID, &threadState );
	addRandomData( randomState, &threadState, sizeof( ThreadState ) );

	/* Get the sound mananger status.  This gets the number of allocated
	   sound channels and the current CPU load from these channels */
	SndManagerStatus( sizeof( SMStatus ), &soundStatus );
	addRandomData( randomState, &soundStatus, sizeof( SMStatus ) );

	/* Get the speech manager version and status */
/*	version = SpeechManagerVersion();
	addRandomData( randomState, &version, sizeof( NumVersion ) );
	addRandomValue( randomState, SpeechBusy() );
*/
	/* Get the status of the serial port.  This gets information on recent
	   errors, read and write pending status, and flow control values */
/*	if( !OpenDriver( "\p.AIn", &driverRefNum ) )
		{
		SerStaRec serialStatus;

		SetStatus( driverRefNum, &serialStatus );
		addRandomData( randomState, &serialStatus, sizeof( SerStaRec ) );
		}
	if( !OpenDriver( "\p.AOut", &driverRefNum ) )
		{
		SerStaRec serialStatus;

		SetStatus( driverRefNum, &serialStatus );
		addRandomData( randomState, &serialStatus, sizeof( SerStaRec ) );
		} */

	/* Flush any remaining data through */
	endRandomData( randomState, 10 );
	}
Ejemplo n.º 19
0
void LoadNPCList()
{
    const int8* Query =
        "SELECT \
          zoneid,\
          npcid,\
          name,\
          pos_rot,\
          pos_x,\
          pos_y,\
          pos_z,\
          flag,\
          speed,\
          speedsub,\
          animation,\
          animationsub,\
          namevis,\
          status,\
          unknown,\
          look,\
          name_prefix \
        FROM npc_list \
        WHERE npcid < 1024;";

    int32 ret = Sql_Query(SqlHandle, Query);

    if( ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0)
    {
        while(Sql_NextRow(SqlHandle) == SQL_SUCCESS)
        {
            uint16 ZoneID = (uint16)Sql_GetUIntData(SqlHandle, 0);

            if (GetZone(ZoneID)->GetType() != ZONETYPE_DUNGEON_INSTANCED)
            {
                CNpcEntity* PNpc = new CNpcEntity;
                PNpc->targid = (uint16)Sql_GetUIntData(SqlHandle, 1);
                PNpc->id = (uint32)PNpc->targid + (ZoneID << 12) + 0x1000000;

                PNpc->name.insert(0, Sql_GetData(SqlHandle, 2));

                PNpc->loc.p.rotation = (uint8)Sql_GetIntData(SqlHandle, 3);
                PNpc->loc.p.x = Sql_GetFloatData(SqlHandle, 4);
                PNpc->loc.p.y = Sql_GetFloatData(SqlHandle, 5);
                PNpc->loc.p.z = Sql_GetFloatData(SqlHandle, 6);
                PNpc->loc.p.moving = (uint16)Sql_GetUIntData(SqlHandle, 7);

                PNpc->m_TargID = (uint32)Sql_GetUIntData(SqlHandle, 7) >> 16; // вполне вероятно

                PNpc->speed = (uint8)Sql_GetIntData(SqlHandle, 8);
                PNpc->speedsub = (uint8)Sql_GetIntData(SqlHandle, 9);
                PNpc->animation = (uint8)Sql_GetIntData(SqlHandle, 10);
                PNpc->animationsub = (uint8)Sql_GetIntData(SqlHandle, 11);

                PNpc->namevis = (uint8)Sql_GetIntData(SqlHandle, 12);
                PNpc->status = (STATUSTYPE)Sql_GetIntData(SqlHandle, 13);
                PNpc->unknown = (uint32)Sql_GetUIntData(SqlHandle, 14);

                PNpc->name_prefix = (uint8)Sql_GetIntData(SqlHandle, 16);

                memcpy(&PNpc->look, Sql_GetData(SqlHandle, 15), 20);

                GetZone(ZoneID)->InsertNPC(PNpc);
                luautils::OnNpcSpawn(PNpc);
            }
        }
    }
Ejemplo n.º 20
0
static boolean getmenutobuild (bigstring bsmenu, boolean flhierarchic, short *id, hdlmenu *hmenu, boolean *flbuiltin) {
	
	/*
	5.0a24 dmb: before allocating a new menu, see if we want to 
	build onto a builtin menu
	*/
	
	boolean flinfrontier;

	#ifdef flcomponent
		THz savezone;
		#if TARGET_API_MAC_CARBON == 1
		savezone = LMGetApplZone();
		#else
		 savezone = GetZone ();
		 #endif
		
		#endif
	
	#ifdef MACVERSION
		flinfrontier = iscurrentapplication (langipcself);
	#else
		flinfrontier = true;
	#endif
	
	if (flinfrontier && !flhierarchic && shelltgetmainmenu (bsmenu, hmenu, id)) {
		
		*flbuiltin = true;
		
		#ifdef WIN95VERSION
			// about needs to be last, but resource compiler doesn't allow empty menus
			if (*id == helpmenu)
				deletemenuitem (*hmenu, aboutitem);
		#endif
	
		return (true);
		}
	
	*flbuiltin = false;

	if (*id <= 0) { /*allocate a new menu id*/
		
		if (!meallocmenuid (id))
			return (false);
		}
	
	#ifdef flcomponent
		#if TARGET_API_MAC_CARBON == 1
		//Code change by Timothy Paustian Monday, June 26, 2000 9:29:46 PM
		//This code makes no sense to me.
		LMSetApplZone(LMGetApplZone());
		#else		
		SetZone (ApplicationZone ());
		#endif
		
	#endif
	
	*hmenu = Newmenu (*id, bsmenu);
	
	#ifdef flcomponent
		#if TARGET_API_MAC_CARBON == 1
		LMSetApplZone(savezone);
		#else
		SetZone (savezone);
		#endif
		
		
	#endif
	
	return (hmenu != nil);
	} /*getmenutobuild*/
Ejemplo n.º 21
0
GYZone* GYScene::GetZone( const GYPosition& position )
{
	return GetZone(GetZoneID(position));
}
void CAlarmMachine::HandleAdemcoEvent(const ademco::AdemcoEventPtr& ademcoEvent)
{
	AUTO_LOG_FUNCTION;

	// handle ademco event
	if (!_is_submachine) {
#pragma region define val
		bool bMachineStatus = false;
		bool bOnofflineStatus = false;
		bool online = true;
		MachineStatus machine_status = MACHINE_DISARM;
		CZoneInfoPtr zone = GetZone(ademcoEvent->_zone);
		CAlarmMachinePtr subMachine = nullptr;
		if (zone) {
			subMachine = zone->GetSubMachineInfo();
		}
#pragma endregion

#pragma region switch event
		switch (ademcoEvent->_event) {
			case ademco::EVENT_OFFLINE:
				bOnofflineStatus = true; _rcccObj.reset();
				bMachineStatus = true; online = false; 
				break;
			case ademco::EVENT_ONLINE: bOnofflineStatus = true; 
				bMachineStatus = true; 
				break;
			case ademco::EVENT_RETRIEVE_ZONE_OR_SUB_MACHINE:
				HandleRetrieveResult(ademcoEvent);
				return;
				break;
			case ademco::EVENT_QUERY_SUB_MACHINE:
				return;
				break;
			case ademco::EVENT_DISARM: bMachineStatus = true; machine_status = MACHINE_DISARM; 
				break;
			case ademco::EVENT_HALFARM: bMachineStatus = true; machine_status = MACHINE_HALFARM; 
				break;
			case ademco::EVENT_ARM: bMachineStatus = true; machine_status = MACHINE_ARM; 
				break;	
			case ademco::EVENT_EMERGENCY:
			default: bMachineStatus = false;
				break;
		}
#pragma endregion


		if (bMachineStatus) {	// status of machine
			bool bStatusChanged = false;
#pragma region online or armed
			if ((ademcoEvent->_zone == 0) && (ademcoEvent->_sub_zone == INDEX_ZONE)) {				
				_online = online;
				if (!bOnofflineStatus && (_machine_status != machine_status)) {
					bStatusChanged = true;
					_machine_status = (machine_status);
				}
			}
#pragma endregion

#pragma region status event
			if (ademcoEvent->_zone == 0) { // netmachine
				// 2015-06-05 16:35:49 submachine on/off line status follow machine on/off line status
				if (bOnofflineStatus && !_is_submachine) {
					SetAllSubMachineOnOffLine(online);
				} 
			} else { // submachine
				if (subMachine) {
					//subMachine->_online = online;
					if (!bOnofflineStatus) {
						if (!subMachine->get_online()) {
							subMachine->set_online(true);
						}
						if (subMachine->get_machine_status() != machine_status)
							bStatusChanged = true;

						subMachine->_machine_status = machine_status;
						subMachine->SetAdemcoEvent(ademcoEvent->_source,
													ademcoEvent->_event,
													ademcoEvent->_zone,
													ademcoEvent->_sub_zone, 
													ademcoEvent->_timestamp,
													ademcoEvent->_recv_time,
													ademcoEvent->_xdata
													);
					}
				}
			}

#pragma endregion
		} else { // alarm or exception event

#pragma region alarm event
			_alarming = true;

			EventLevel eventLevel = GetEventLevel(ademcoEvent->_event);
			set_highestEventLevel(eventLevel);

			// ui
			// 1. main view btn flash
			CWinApp* app = AfxGetApp(); ASSERT(app);
			auto wnd = static_cast<CAlarmMachineExDlg*>(app->GetMainWnd()); ASSERT(wnd);
			wnd->MachineAlarm(shared_from_this());

			if (subMachine) {
				if (!subMachine->get_alarming()) {
					subMachine->set_alarming(true);
					_alarmingSubMachineCount++;
				}
				subMachine->set_highestEventLevel(GetEventLevel(ademcoEvent->_event));
				subMachine->HandleAdemcoEvent(ademcoEvent);
			} else {
				_has_alarming_direct_zone = true;
			}

			
#pragma endregion
		}
	} 
	emit();
}
Ejemplo n.º 23
0
void LoadMOBList()
{
    const int8* Query =
        "SELECT zoneid, name, mobid, pos_rot, pos_x, pos_y, pos_z, \
			respawntime, spawntype, dropid, mob_groups.HP, mob_groups.MP, minLevel, maxLevel, \
			modelid, mJob, sJob, cmbSkill, cmbDmgMult, cmbDelay, behavior, links, mobType, immunity, \
			systemid, mobsize, speed, \
			STR, DEX, VIT, AGI, `INT`, MND, CHR, EVA, DEF, \
			Slash, Pierce, H2H, Impact, \
			Fire, Ice, Wind, Earth, Lightning, Water, Light, Dark, Element, \
			mob_pools.familyid, name_prefix, unknown, animationsub, \
			(mob_family_system.HP / 100), (mob_family_system.MP / 100), hasSpellScript, spellList, ATT, ACC, mob_groups.poolid \
			FROM mob_groups INNER JOIN mob_pools ON mob_groups.poolid = mob_pools.poolid \
			INNER JOIN mob_spawn_points ON mob_groups.groupid = mob_spawn_points.groupid \
			INNER JOIN mob_family_system ON mob_pools.familyid = mob_family_system.familyid \
			WHERE NOT (pos_x = 0 AND pos_y = 0 AND pos_z = 0);";

    int32 ret = Sql_Query(SqlHandle, Query);

	if( ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0)
	{
		while(Sql_NextRow(SqlHandle) == SQL_SUCCESS)
		{
        	uint16 ZoneID = (uint16)Sql_GetUIntData(SqlHandle, 0);
			CMobEntity* PMob = new CMobEntity;

			PMob->name.insert(0,Sql_GetData(SqlHandle,1));
			PMob->id = (uint32)Sql_GetUIntData(SqlHandle,2);
			PMob->targid = (uint16)PMob->id & 0x0FFF;

			PMob->m_SpawnPoint.rotation = (uint8)Sql_GetIntData(SqlHandle,3);
			PMob->m_SpawnPoint.x = Sql_GetFloatData(SqlHandle,4);
			PMob->m_SpawnPoint.y = Sql_GetFloatData(SqlHandle,5);
			PMob->m_SpawnPoint.z = Sql_GetFloatData(SqlHandle,6);

			PMob->m_RespawnTime = Sql_GetUIntData(SqlHandle,7) * 1000;
			PMob->m_SpawnType   = (SPAWNTYPE)Sql_GetUIntData(SqlHandle,8);
			PMob->m_DropID		= Sql_GetUIntData(SqlHandle,9);

			PMob->HPmodifier = (uint32)Sql_GetIntData(SqlHandle,10);
			PMob->MPmodifier = (uint32)Sql_GetIntData(SqlHandle,11);

			PMob->m_minLevel = (uint8)Sql_GetIntData(SqlHandle,12);
			PMob->m_maxLevel = (uint8)Sql_GetIntData(SqlHandle,13);

			memcpy(&PMob->look,Sql_GetData(SqlHandle,14),23);

			PMob->SetMJob(Sql_GetIntData(SqlHandle,15));
			PMob->SetSJob(Sql_GetIntData(SqlHandle,16));

			PMob->m_Weapons[SLOT_MAIN]->setMaxHit(1);
			PMob->m_Weapons[SLOT_MAIN]->setSkillType(Sql_GetIntData(SqlHandle,17));
			PMob->m_dmgMult = Sql_GetUIntData(SqlHandle, 18);
			PMob->m_Weapons[SLOT_MAIN]->setDelay((Sql_GetIntData(SqlHandle,19) * 1000)/60);
			PMob->m_Weapons[SLOT_MAIN]->setBaseDelay((Sql_GetIntData(SqlHandle,19) * 1000)/60);

			PMob->m_Behaviour  = (uint16)Sql_GetIntData(SqlHandle,20);
			PMob->m_Link       = (uint8)Sql_GetIntData(SqlHandle,21);
			PMob->m_Type       = (uint8)Sql_GetIntData(SqlHandle,22);
			PMob->m_Immunity   = (IMMUNITY)Sql_GetIntData(SqlHandle,23);
			PMob->m_EcoSystem  = (ECOSYSTEM)Sql_GetIntData(SqlHandle,24);
			PMob->m_ModelSize += (uint8)Sql_GetIntData(SqlHandle,25);

			PMob->speed    = (uint8)Sql_GetIntData(SqlHandle,26);
			PMob->speedsub = (uint8)Sql_GetIntData(SqlHandle,26);

			/*if(PMob->speed != 0)
			{
				PMob->speed += map_config.speed_mod;
                // whats this for?
				PMob->speedsub += map_config.speed_mod;
			}*/

            PMob->strRank = (uint8)Sql_GetIntData(SqlHandle,27);
            PMob->dexRank = (uint8)Sql_GetIntData(SqlHandle,28);
            PMob->vitRank = (uint8)Sql_GetIntData(SqlHandle,29);
            PMob->agiRank = (uint8)Sql_GetIntData(SqlHandle,30);
            PMob->intRank = (uint8)Sql_GetIntData(SqlHandle,31);
            PMob->mndRank = (uint8)Sql_GetIntData(SqlHandle,32);
            PMob->chrRank = (uint8)Sql_GetIntData(SqlHandle,33);
            PMob->evaRank = (uint8)Sql_GetIntData(SqlHandle,34);
            PMob->defRank = (uint8)Sql_GetIntData(SqlHandle,35);
            PMob->attRank = (uint8)Sql_GetIntData(SqlHandle,57);
            PMob->accRank = (uint8)Sql_GetIntData(SqlHandle,58);

			PMob->setModifier(MOD_SLASHRES, (uint16)(Sql_GetFloatData(SqlHandle,36) * 1000));
			PMob->setModifier(MOD_PIERCERES,(uint16)(Sql_GetFloatData(SqlHandle,37) * 1000));
			PMob->setModifier(MOD_HTHRES,   (uint16)(Sql_GetFloatData(SqlHandle,38) * 1000));
			PMob->setModifier(MOD_IMPACTRES,(uint16)(Sql_GetFloatData(SqlHandle,39) * 1000));

            PMob->setModifier(MOD_FIREDEF,    (int16)((Sql_GetFloatData(SqlHandle, 40) - 1) * -1000)); // These are stored as floating percentages
            PMob->setModifier(MOD_ICEDEF,     (int16)((Sql_GetFloatData(SqlHandle, 41) - 1) * -1000)); // and need to be adjusted into modifier units.
            PMob->setModifier(MOD_WINDDEF,    (int16)((Sql_GetFloatData(SqlHandle, 42) - 1) * -1000)); // Higher DEF = lower damage.
            PMob->setModifier(MOD_EARTHDEF,   (int16)((Sql_GetFloatData(SqlHandle, 43) - 1) * -1000)); // Negatives signify increased damage.
            PMob->setModifier(MOD_THUNDERDEF, (int16)((Sql_GetFloatData(SqlHandle, 44) - 1) * -1000)); // Positives signify reduced damage.
            PMob->setModifier(MOD_WATERDEF,   (int16)((Sql_GetFloatData(SqlHandle, 45) - 1) * -1000)); // Ex: 125% damage would be 1.25, 50% damage would be 0.50
            PMob->setModifier(MOD_LIGHTDEF,   (int16)((Sql_GetFloatData(SqlHandle, 46) - 1) * -1000)); // (1.25 - 1) * -1000 = -250 DEF
            PMob->setModifier(MOD_DARKDEF,    (int16)((Sql_GetFloatData(SqlHandle, 47) - 1) * -1000)); // (0.50 - 1) * -1000 = 500 DEF

            PMob->setModifier(MOD_FIRERES,    (int16)((Sql_GetFloatData(SqlHandle, 40) - 1) * -100)); // These are stored as floating percentages
            PMob->setModifier(MOD_ICERES,     (int16)((Sql_GetFloatData(SqlHandle, 41) - 1) * -100)); // and need to be adjusted into modifier units.
            PMob->setModifier(MOD_WINDRES,    (int16)((Sql_GetFloatData(SqlHandle, 42) - 1) * -100)); // Higher RES = lower damage.
            PMob->setModifier(MOD_EARTHRES,   (int16)((Sql_GetFloatData(SqlHandle, 43) - 1) * -100)); // Negatives signify lower resist chance.
            PMob->setModifier(MOD_THUNDERRES, (int16)((Sql_GetFloatData(SqlHandle, 44) - 1) * -100)); // Positives signify increased resist chance.
            PMob->setModifier(MOD_WATERRES,   (int16)((Sql_GetFloatData(SqlHandle, 45) - 1) * -100));
            PMob->setModifier(MOD_LIGHTRES,   (int16)((Sql_GetFloatData(SqlHandle, 46) - 1) * -100));
            PMob->setModifier(MOD_DARKRES,    (int16)((Sql_GetFloatData(SqlHandle, 47) - 1) * -100));

			PMob->m_Element = (uint8)Sql_GetIntData(SqlHandle,48);
			PMob->m_Family = (uint16)Sql_GetIntData(SqlHandle,49);
			PMob->m_name_prefix = (uint8)Sql_GetIntData(SqlHandle,50);
			PMob->m_unknown = (uint32)Sql_GetIntData(SqlHandle,51);

			//Special sub animation for Mob (yovra, jailer of love, phuabo)
			// yovra 1: en hauteur, 2: en bas, 3: en haut
			// phuabo 1: sous l'eau, 2: sort de l'eau, 3: rentre dans l'eau
			PMob->animationsub = (uint32)Sql_GetIntData(SqlHandle,52);

			// Setup HP / MP Stat Percentage Boost
			PMob->HPscale = Sql_GetFloatData(SqlHandle,53);
			PMob->MPscale = Sql_GetFloatData(SqlHandle,54);

			PMob->PBattleAI = new CAIMobDummy(PMob);

			if (PMob->m_AllowRespawn = PMob->m_SpawnType == SPAWNTYPE_NORMAL)
			{
				PMob->PBattleAI->SetCurrentAction(ACTION_SPAWN);
			}

			// Check if we should be looking up scripts for this mob
			PMob->m_HasSpellScript = (uint8)Sql_GetIntData(SqlHandle,55);

			PMob->m_SpellListContainer = mobSpellList::GetMobSpellList(Sql_GetIntData(SqlHandle,56));

			PMob->m_Pool = Sql_GetUIntData(SqlHandle,59);

            // must be here first to define mobmods
			mobutils::InitializeMob(PMob, GetZone(ZoneID));

            GetZone(ZoneID)->InsertMOB(PMob);

            luautils::OnMobInitialize(PMob);

            PMob->saveModifiers();
            PMob->saveMobModifiers();
		}
	}

	// attach pets to mobs
	const int8* PetQuery =
		"SELECT zoneid, mob_mobid, pet_offset \
		FROM mob_pets \
		LEFT JOIN mob_spawn_points ON mob_pets.mob_mobid = mob_spawn_points.mobid \
		LEFT JOIN mob_groups ON mob_spawn_points.groupid = mob_groups.groupid;";

	ret = Sql_Query(SqlHandle, PetQuery);

	if( ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0)
	{
		while(Sql_NextRow(SqlHandle) == SQL_SUCCESS)
		{
        	uint16 ZoneID = (uint16)Sql_GetUIntData(SqlHandle, 0);
			uint32 masterid = (uint32)Sql_GetUIntData(SqlHandle,1);
			uint32 petid = masterid + (uint32)Sql_GetUIntData(SqlHandle,2);

			CMobEntity* PMaster = (CMobEntity*)GetZone(ZoneID)->GetEntity(masterid & 0x0FFF, TYPE_MOB);
			CMobEntity* PPet = (CMobEntity*)GetZone(ZoneID)->GetEntity(petid & 0x0FFF, TYPE_MOB);

			if(PMaster == NULL)
			{
				ShowError("zoneutils::loadMOBList PMaster is null. masterid: %d. Make sure x,y,z are not zeros, and that all entities are entered in the database!\n", masterid);
			}
			else if(PPet == NULL)
			{
				ShowError("zoneutils::loadMOBList PPet is null. petid: %d. Make sure x,y,z are not zeros!\n", petid);
			}
			else if(masterid == petid)
			{
				ShowError("zoneutils::loadMOBList Master and Pet are the same entity: %d\n", masterid);
			}
			else
			{
				// pet is always spawned by master
				PPet->m_AllowRespawn = false;
				PPet->m_SpawnType = SPAWNTYPE_SCRIPTED;
				PPet->PBattleAI->SetCurrentAction(ACTION_NONE);
				PPet->SetDespawnTimer(0);

				PMaster->PPet = PPet;
				PPet->PMaster = PMaster;
			}
		}
	}
}
Ejemplo n.º 24
0
	g_PTrigger->id = ((4096 + ZoneID) << 12) + TargID;

    ShowWarning(CL_YELLOW"Server need NPC <%u>\n" CL_RESET, g_PTrigger->id);
	return g_PTrigger;
}

/************************************************************************
*                                                                       *
*  Получаем указатель на любую сущность по ID                           *
*                                                                       *
************************************************************************/

CBaseEntity* GetEntity(uint32 ID, uint8 filter)
{
	uint16 zoneID = (ID >> 12) & 0x0FFF;
	CZone* PZone = GetZone(zoneID);
	if (PZone)
	{
		return PZone->GetEntity((uint16)(ID & 0x0FFF), filter);
	}
	else
	{
		return nullptr;
	}
}

/************************************************************************
*                                                                       *
*  Получаем указатель на персонажа по имени                             *
*                                                                       *
************************************************************************/