// MixerTest_DoMenuItem() // ----------------------------------------------------- // // void MixerTest_DoMenuItem(int menu, int subMenu) { BAEResult err; err = BAE_NO_ERROR; switch (menu) { case 1: err = DoScript(subMenu); break; case 2: err = DoFunction(subMenu); break; case 3: err = DoTest(subMenu); break; default: break; } if (err) { printf("\a! Error code: %s (%d)\n", BAEResultToStr(err), (int)err); } else { printf("OK.\n"); } }
int DoScript(const char *str) { return DoScript(lua::Str(str)); }
/* KeyManager - intercept keystrokes and hand them to the active window * * We use the top of winList as the current input focus. All input is handed * to the window procedure EXCEPT for the tab key. The tab key is responsible * for placing the top window on the bottom of the stack to cycle through the * set of windows. * */ VOID PASCAL INTERNAL KeyManager (VOID) { LONG now; #if defined (HEAPCRAP) INT fHeapChk; #endif /* do script first in case in contains a password command */ if ( pInitScript ) DoScript ( hCommand, pInitScript, 0 ); if (fMailAllowed) { GetAliases ( fNotifyTools & F_LOADALIAS ); fNotifyTools &= ~(FLAG)F_LOADALIAS; NotifyTools ( ); } if ( fComposeOnBoot ) ( *( winList->wndProc ) ) ( winList, KEY, 0 ); SendMessage ( hCommand, DISPPROMPT, TRUE ); while ( ( winList != NULL ) && ( !fQuit ) ) { time ( &now ); CheckTimeDisplay ( now ); if ( pInitHdrCmd ) { DoHeaders ( hCommand, pInitHdrCmd, TRUE ); SendMessage ( hCommand, DISPPROMPT, 0 ); ZMfree ( pInitHdrCmd ); pInitHdrCmd = NULL; } /* if system has not received a char for 10 sec then checkmail */ if (fMailAllowed) CheckMail ( now ); /* time out password after (default) 6 hours in case user has * left WZMAIL running and gone home */ if ( now > lTmPassword + lPasswordAge ) ResetPassword ( ); if ( now > lTmConnect + cSecConnect ) ZMDisconnect ( ); /* On multitasking systems, it is rude to go into polling loops. * * For OS/2, we have a separate thread dedicated to reading from the * console. We clear a semaphore to let him read and then wait on * a response semaphore with the specified timeout. This avoids * polling. * * For real mode DOS, we presume that INT 16 (poll) will cause an * explicit yield to other runnable threads. */ if (kbwait (60 * 1000)) { fMailUnSeen = FALSE; do { (*winList->wndProc) ( winList, KEY, ReadKey() ); } while (!fQuit && kbwait (10000)); } #if defined (HEAPCRAP) if ( ( fHeapChk = heapchk ( ) ) != HEAPOK ) { fprintf ( stderr, "%s\n", ( fHeapChk == HEAPBADBEGIN ? "Can't find heap" : "Damaged heap" ) ); assert ( fHeapChk == HEAPOK ); } #endif } return; }
void GameEventMgr::ProcessObjectsAndScriptsProc(QueryResultVector & results, uint32 id) { // process scripts if(QueryResult *query = results[0].result) { do { Field * f = query->Fetch(); uint32 mapid = f[1].GetUInt32(); uint32 sql_id = f[2].GetUInt32(); uint8 type = f[3].GetUInt8(); uint32 data1 = f[4].GetUInt32(); uint32 data2 = f[5].GetUInt32(); uint32 data3 = f[6].GetUInt32(); char * say = strdup(f[7].GetString()); DoScript(id, sql_id, type, data1, data2, data3, say, mapid); } while(query->NextRow()); } // waypoints -- the created objects will be deleted automatically by creature class on despawn std::map<uint32, std::map<uint32, std::list<WayPoint *>>> waypoints; if(QueryResult *query = results[1].result) { do { Field * f = query->Fetch(); WayPoint *wp = new WayPoint; //uint32 event = f[0].GetUInt32(); uint32 spawnid = f[1].GetUInt32(); wp->id = f[2].GetUInt32(); wp->x = f[3].GetFloat(); wp->y = f[4].GetFloat(); wp->z = f[5].GetFloat(); wp->waittime = f[6].GetUInt32(); wp->flags = f[7].GetUInt32(); wp->forwardemoteoneshot = f[8].GetBool(); wp->forwardemoteid = f[9].GetUInt32(); wp->backwardemoteoneshot = f[10].GetBool(); wp->backwardemoteid = f[11].GetUInt32(); wp->forwardskinid = f[12].GetUInt32(); wp->backwardskinid = f[13].GetUInt32(); waypoints[id][spawnid].push_back(wp); } while(query->NextRow()); } // creature spawns if(QueryResult *query = results[2].result) { do { Field * f = query->Fetch(); CreatureSpawn spawn; //uint32 event = f[0].GetUInt32(); uint32 spawn_id = f[1].GetUInt32(); spawn.id = 0; spawn.entry = f[2].GetUInt32(); uint32 mapid = f[3].GetUInt32(); spawn.x = f[4].GetFloat(); spawn.y = f[5].GetFloat(); spawn.z = f[6].GetFloat(); spawn.o = f[7].GetFloat(); spawn.form = NULL; spawn.movetype = f[8].GetUInt8(); spawn.displayid = f[9].GetUInt32(); spawn.factionid = f[10].GetUInt32(); spawn.flags = f[11].GetUInt32(); spawn.bytes0 = f[12].GetUInt32(); spawn.bytes1 = f[13].GetUInt32(); spawn.bytes2 = f[14].GetUInt32(); spawn.emote_state = f[15].GetUInt32(); //uint32 npc_respawn_link = f[17].GetUInt32(); spawn.channel_spell = f[17].GetUInt16(); spawn.channel_target_go = f[18].GetUInt32(); spawn.channel_target_creature = f[19].GetUInt32(); spawn.stand_state = f[20].GetUInt16(); spawn.death_state = f[21].GetUInt32(); spawn.MountedDisplayID = f[22].GetUInt32(); spawn.Item1SlotDisplay = f[23].GetUInt32(); spawn.Item2SlotDisplay = f[24].GetUInt32(); spawn.Item3SlotDisplay = f[25].GetUInt32(); spawn.CanFly = f[26].GetUInt32(); spawn.phase = f[27].GetUInt32(); if(spawn.phase == 0) spawn.phase = 0xFFFFFFFF; CreatureProto* proto = CreatureProtoStorage.LookupEntry(spawn.entry); CreatureInfo* info = CreatureNameStorage.LookupEntry(spawn.entry); if(proto == NULL || info == NULL) { continue; } // get mapmgr for spawn MapMgr * mgr = sInstanceMgr.GetMapMgr(mapid); if(mgr == NULL) { // So this is a really interesting situation! Log.Success("GameEvent","Failed to spawn creature spawn %u for event %u on nonexistant map %u", spawn.id, id, mapid); continue; } // spawn the creature //Creature * crt = mgr->GetInterface()->SpawnCreature(&spawn, true); Creature * crt = mgr->CreateCreature(spawn.entry); if(crt == NULL) { // we didnt succeed creating the creature! Print a warning and go on Log.Success("GameEvent","Failed to spawn creature spawn %u for event %u", spawn.id, id); continue; } crt->Load(&spawn, 0, mgr->GetMapInfo()); crt->spawnid = 0; crt->m_spawn = NULL; // add waypoints crt->m_custom_waypoint_map = new WayPointMap(); for(std::list<WayPoint *>::iterator itr = waypoints[id][spawn_id].begin(); itr != waypoints[id][spawn_id].end(); itr++) { // use custom waypoint map, so we avoid saving it to database crt->m_custom_waypoint_map->push_back(*itr); } crt->GetAIInterface()->SetWaypointMap(crt->m_custom_waypoint_map); crt->AddToWorld(mgr); m_creaturespawns[id][mapid].push_back(crt->GetUIdFromGUID()); } while(query->NextRow()); } // gameobject spawns if(QueryResult *query = results[3].result) { do { Field * f = query->Fetch(); GOSpawn spawn; //uint32 event = f[0].GetUInt32(); uint32 spawn_id = f[1].GetUInt32(); // generate new ingame sql id spawn.id = /*objmgr.GenerateCreatureSpawnID()*/0; spawn.entry = f[2].GetUInt32(); uint32 mapid = f[3].GetUInt32(); spawn.x = f[4].GetFloat(); spawn.y = f[5].GetFloat(); spawn.z = f[6].GetFloat(); spawn.facing = f[7].GetFloat(); spawn.o = f[8].GetFloat(); spawn.o1 = f[9].GetFloat(); spawn.o2 = f[10].GetFloat(); spawn.o3 = f[11].GetFloat(); spawn.state = f[12].GetUInt32(); spawn.flags = f[13].GetUInt32(); spawn.faction = f[14].GetUInt32(); spawn.scale = f[15].GetFloat(); //uint32 state_npc_link = fields[16].GetUInt32(); spawn.phase = f[17].GetUInt32(); if(spawn.phase == 0) spawn.phase = 0xFFFFFFFF; spawn.overrides = f[18].GetUInt32(); // get mapmgr for spawn MapMgr * mgr = sInstanceMgr.GetMapMgr(mapid); if(mgr == NULL) { // So this is a really interesting situation! Log.Success("GameEvent","Failed to spawn gameobject spawn %u for event %u on nonexistant map %u", spawn.id, id, mapid); continue; } // spawn the creature GameObject * go = mgr->CreateGameObject(spawn.entry); if(go == NULL) { // we didnt succeed creating the creature! Print a warning and go on Log.Success("GameEvent","Failed to spawn gameobject spawn %u for event %u", spawn.id, id); continue; } go->Load(&spawn); go->m_spawn = NULL; go->AddToWorld(mgr); m_gameobjectspawns[id][mapid].push_back(go->GetUIdFromGUID()); } while(query->NextRow()); } Log.Success("GameEvent","event %u spawned.", id); }