本文整理汇总了C++中spawn函数的典型用法代码示例。如果您正苦于以下问题:C++ spawn函数的具体用法?C++ spawn怎么用?C++ spawn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了spawn函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: spawn_monster
void spawn_monster() {
auto monster = spawn().lock();
monster->act = monster_act;
while(1) {
AxialPosition p;
int x = rnd(0, (int)game.map->width);
int y = rnd(0, (int)game.map->height);
game.map->from_data_coord(x, y, p);
if(game.map->empty(p)) {
monster->position = p;
break;
}
}
monster->energy_gain = rnd(100, 300);
add_message("Added monster with %i energy gain", monster->energy_gain);
}
示例2: while
void Emitter::update(float dt)
{
accumulated_time_ += dt;
while (accumulated_time_ >= spawn_rate_)
{
accumulated_time_ -= spawn_rate_;
instances_.push_back(spawn());
}
size_t number = instances_.size();
for (size_t i = 0; i < number; i++)
{
instances_[i]->update(dt);
if (instances_[i]->done())
{
delete instances_[i];
std::swap(instances_[i],instances_[number-1]);
number--;
}
}
instances_.erase(instances_.begin() + number,instances_.end());
}
示例3: runorraise
void
runorraise(const Arg *arg) {
const char **app = arg->v;
Arg a = { .ui = ~0 };
Monitor *mon;
Client *c;
XClassHint hint = { NULL, NULL };
/* Tries to find the client */
for (mon = mons; mon; mon = mon->next) {
for (c = mon->clients; c; c = c->next) {
XGetClassHint(dpy, c->win, &hint);
if (hint.res_class && strcmp(app[2], hint.res_class) == 0) {
a.ui = c->tags;
view(&a);
focus(c);
return;
}
}
}
/* Client not found: spawn it */
spawn(arg);
}
示例4: make_bubbles
void make_bubbles()
{
gedict_t *bubble;
bubble = spawn();
setmodel( bubble, "progs/s_bubble.spr" );
setorigin( bubble, PASSVEC3( self->s.v.origin ) );
bubble->s.v.movetype = MOVETYPE_NOCLIP;
bubble->s.v.solid = SOLID_NOT;
SetVector( bubble->s.v.velocity, 0, 0, 15 );
bubble->s.v.nextthink = g_globalvars.time + 0.5;
bubble->think = ( func_t ) bubble_bob;
bubble->touch = ( func_t ) bubble_remove;
bubble->classname = "bubble";
bubble->s.v.frame = 0;
bubble->cnt = 0;
setsize( bubble, -8, -8, -8, 8, 8, 8 );
self->s.v.nextthink = g_globalvars.time + g_random() + 0.5;
self->think = ( func_t ) make_bubbles;
}
示例5: spawn_tdeath
void spawn_tdeath( vec3_t org, gedict_t * death_owner )
{
gedict_t *death;
death = spawn();
death->s.v.classname = "teledeath";
death->s.v.movetype = MOVETYPE_NONE;
death->s.v.solid = SOLID_TRIGGER;
SetVector( death->s.v.angles, 0, 0, 0 );
setsize( death, death_owner->s.v.mins[0] - 1, death_owner->s.v.mins[1] - 1,
death_owner->s.v.mins[2] - 1, death_owner->s.v.maxs[0] + 1,
death_owner->s.v.maxs[1] + 1, death_owner->s.v.maxs[2] + 1 );
setorigin( death, PASSVEC3( org ) );
death->s.v.touch = ( func_t ) tdeath_touch;
death->s.v.nextthink = g_globalvars.time + 0.2;
death->s.v.think = ( func_t ) SUB_Remove;
death->s.v.owner = EDICT_TO_PROG( death_owner );
g_globalvars.force_retouch = 2; // make sure even still objects get hit
}
示例6: do_stop
/*
* This function simply stops the service p.
* @param s A Service_T object
* @param flag TRUE if the monitoring should be disabled or FALSE if monitoring should continue (when stop is part of restart)
* @return TRUE if the service was stopped otherwise FALSE
*/
static int do_stop(Service_T s, int flag) {
int rv = TRUE;
ASSERT(s);
if (s->depend_visited)
return rv;
s->depend_visited = TRUE;
if (s->stop) {
if (s->type != TYPE_PROCESS || Util_isProcessRunning(s, FALSE)) {
LogInfo("'%s' stop: %s\n", s->name, s->stop->arg[0]);
spawn(s, s->stop, NULL);
if (s->type == TYPE_PROCESS && (wait_process(s, Process_Stopped) != Process_Stopped)) // Only wait for process service types stop
rv = FALSE;
}
} else {
LogDebug("'%s' stop skipped -- method not defined\n", s->name);
}
if (flag)
Util_monitorUnset(s);
else
Util_resetInfo(s);
return rv;
}
示例7: agent_spawn
void
agent_spawn (bool opt_verbose)
{
// start agent if needed (sfsagent -c)
if (!isagentrunning ()) {
if (opt_verbose)
warn << "No existing agent found; spawning a new one...\n";
str sa = find_program ("sfsagent");
vec<char *> av;
av.push_back (const_cast<char *> (sa.cstr ()));
av.push_back ("-c");
av.push_back (NULL);
pid_t pid = spawn (av[0], av.base ());
if (waitpid (pid, NULL, 0) < 0)
fatal << "Could not spawn a new SFS agent: " <<
strerror (errno) << "\n";
}
else {
if (opt_verbose)
warn << "Contacting existing agent...\n";
}
}
示例8: mainloop
/** WMFS main loop.
*/
static void
mainloop(void)
{
XEvent ev;
pthread_t th_status;
if (estatus && conf.status_timing == 0)
conf.status_pid = spawn(conf.status_path);
else if (estatus && pthread_create(&th_status, NULL, thread_status, NULL) != 0) {
warnx("pthread_create");
estatus = False;
}
while (!exiting && !XNextEvent(dpy, &ev)) {
getevent(ev);
wait_childs_and_status();
}
if (estatus)
pthread_join(th_status, NULL);
return;
}
示例9: HoloDood
// spawn the actual holo
void HoloDood ( )
{
gedict_t *holo;
vec3_t vtemp;
sound( self, 1, "weapons/railgr1a.wav", 0.6, 1 );
holo = spawn( );
holo->s.v.owner = EDICT_TO_PROG( self );
vtemp[0] =
self->s.v.origin[0];
vtemp[1] =
self->s.v.origin[1];
vtemp[2] =
self->s.v.origin[2] + 24;
setorigin( holo, PASSVEC3( vtemp ) );
holo->s.v.angles[1] = self->s.v.angles[1];
holo->s.v.angles[0] = self->s.v.angles[0];
holo->s.v.skin = self->s.v.skin;
holo->s.v.frame = self->s.v.frame;
holo->s.v.colormap = self->s.v.colormap;
holo->s.v.flags = 256;
holo->s.v.solid = SOLID_TRIGGER;
holo->s.v.effects = EF_DIMLIGHT;
holo->s.v.movetype = MOVETYPE_TOSS;
setmodel( holo, "progs/player.mdl" );
setsize( holo, -16, -16, -24, 16, 16, 32 );
holo->s.v.classname = "holo";
holo->playerclass = 0;
holo->s.v.nextthink = g_globalvars.time + 1;
holo->s.v.think = ( func_t ) HoloHumm;
trap_WriteByte( MSG_MULTICAST, SVC_TEMPENTITY );
trap_WriteByte( MSG_MULTICAST, 11 );
trap_WriteCoord( MSG_MULTICAST, self->s.v.origin[0] );
trap_WriteCoord( MSG_MULTICAST, self->s.v.origin[1] );
trap_WriteCoord( MSG_MULTICAST, self->s.v.origin[2] );
trap_multicast( PASSVEC3( self->s.v.origin ), 1 );
}
示例10: run_main
int
run_main (int, ACE_TCHAR *[])
{
ACE_START_TEST (ACE_TEXT ("MM_Shared_Memory_Test"));
#if !defined (ACE_LACKS_MMAP) && !defined (ACE_DISABLE_MKTEMP)
ACE_TCHAR temp_file[MAXPATHLEN + 1];
// Get the temporary directory,
// The - 24 is for the filename, mm_shared_mem_testXXXXXX
if (ACE::get_temp_dir (temp_file, MAXPATHLEN - 24) == -1)
ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Temporary path too long\n")), -1);
// Add the filename to the end
ACE_OS::strcat (temp_file, ACE_TEXT ("mm_shared_mem_testXXXXXX"));
// Store in the global variable.
shm_key = temp_file;
if (ACE_OS::mktemp (shm_key) == 0
|| (ACE_OS::unlink (shm_key) == -1
&& errno == EPERM))
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("(%P|%t) %p\n"),
shm_key),
1);
spawn ();
#else /* !ACE_LACKS_MMAP */
ACE_ERROR ((LM_INFO,
ACE_TEXT ("mmap and mktemp")
ACE_TEXT ("are required for this test\n")));
#endif /* !ACE_LACKS_MMAP */
ACE_END_TEST;
return 0;
}
示例11: SpectatorConnect
////////////////
// GlobalParams:
// time
// self
// params
///////////////
void SpectatorConnect()
{
gedict_t *p;
int diff = (int)(PROG_TO_EDICT(self->s.v.goalentity) - world);
if ( !SpecCanConnect( self ) )
{
stuffcmd(self, "disconnect\n"); // FIXME: stupid way
return;
}
SpecDecodeLevelParms();
self->ct = ctSpec;
self->s.v.classname = "spectator"; // Added this in for kick code
self->k_accepted = 1; // spectator has no restriction to connect
for ( p = world; (p = ( match_in_progress == 2 && !cvar("k_ann") ) ? find_spc( p ) : find_client( p )); )
if ( p != self ) // does't show msg for self
G_sprint( p, PRINT_HIGH, "Spectator %s entered the game\n", self->s.v.netname );
if ( diff < 0 || diff >= MAX_EDICTS ) // something wrong happen - fixing
self->s.v.goalentity = EDICT_TO_PROG( world );
VIP_ShowRights( self );
CheckRate(self, "");
if ( match_in_progress != 2 ) {
self->wizard = spawn();
self->wizard->s.v.classname = "spectator_wizard";
self->wizard->s.v.think = ( func_t ) wizard_think;
self->wizard->s.v.nextthink = g_globalvars.time + 0.1;
}
// Wait until you do stuffing
MakeMOTD();
}
示例12: run
/**
* Run a script. argv[2] is already NULL.
*/
static int run(char *argv[3], struct in_addr *ip)
{
int status;
char *addr = addr; /* for gcc */
const char *fmt = "%s %s %s" + 3;
VDBG("%s run %s %s\n", intf, argv[0], argv[1]);
if (ip) {
addr = inet_ntoa(*ip);
setenv("ip", addr, 1);
fmt -= 3;
}
bb_info_msg(fmt, argv[1], intf, addr);
status = wait4pid(spawn(argv));
if (status < 0) {
bb_perror_msg("%s %s %s" + 3, argv[1], intf);
return -errno;
}
if (status != 0)
bb_error_msg("script %s %s failed, exitcode=%d", argv[0], argv[1], status);
return status;
}
示例13: spawn
void CreatureManager::loadSpawns(const std::string& fileName)
{
if(!isLoaded()) {
g_logger.warning("creatures aren't loaded yet to load spawns.");
return;
}
if(m_spawnLoaded) {
g_logger.warning("attempt to reload spawns.");
return;
}
try {
TiXmlDocument doc;
doc.Parse(g_resources.readFileContents(fileName).c_str());
if(doc.Error())
stdext::throw_exception(stdext::format("cannot load spawns xml file '%s: '%s'", fileName, doc.ErrorDesc()));
TiXmlElement* root = doc.FirstChildElement();
if(!root || root->ValueStr() != "spawns")
stdext::throw_exception("malformed spawns file");
for(TiXmlElement* node = root->FirstChildElement(); node; node = node->NextSiblingElement()) {
if(node->ValueTStr() != "spawn")
stdext::throw_exception("invalid spawn node");
SpawnPtr spawn(new Spawn);
spawn->load(node);
m_spawns.insert(std::make_pair(spawn->getCenterPos(), spawn));
}
doc.Clear();
m_spawnLoaded = true;
} catch(std::exception& e) {
g_logger.error(stdext::format("Failed to load '%s': %s", fileName, e.what()));
}
}
示例14: cvar
gedict_t *ThrowGib( char *gibname, float dm )
{
gedict_t *newent;
int k_short_gib = cvar( "k_short_gib" ); // if set - remove faster
newent = spawn();
VectorCopy( self->s.v.origin, newent->s.v.origin );
setmodel( newent, gibname );
setsize( newent, 0, 0, 0, 0, 0, 0 );
VelocityForDamage( dm, newent->s.v.velocity );
newent->s.v.movetype = MOVETYPE_BOUNCE;
newent->isMissile = true;
newent->s.v.solid = SOLID_NOT;
newent->s.v.avelocity[0] = g_random() * 600;
newent->s.v.avelocity[1] = g_random() * 600;
newent->s.v.avelocity[2] = g_random() * 600;
newent->think = ( func_t ) SUB_Remove;
newent->s.v.ltime = g_globalvars.time;
newent->s.v.nextthink = g_globalvars.time + ( k_short_gib ? 2 : ( 10 + g_random() * 10 ) );
newent->s.v.frame = 0;
newent->s.v.flags = 0;
return newent;
}
示例15: main
int main (int argc, char *argv[]){
char* arg_list[10] = {};
/*no argmuments*/
if(argc <= 1){
childParent();
return 0;
}else if(argc == 2){/*one argument*/
spawnOne(argv[1]);
}else{/*multiple arguments*/
int i = 0;
while(i<argc){
if(i+1==argc){
arg_list[i] = NULL;
}
else{
arg_list[i] = argv[i+1];
}
i++;
}
spawn (argv[1], arg_list);
}
printf("done with main program\n");
return 0;
}