这篇教程C++ CP函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CP函数的典型用法代码示例。如果您正苦于以下问题:C++ CP函数的具体用法?C++ CP怎么用?C++ CP使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CP函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: G_xpsave_loadqboolean G_xpsave_load(gentity_t *ent){ int i, j; qboolean found = qfalse, XPSMuted = qfalse; int clientNum; g_xpsave_t *x = g_xpsaves[0]; time_t t; char agestr[MAX_STRING_CHARS]; //char desc[64]; // josh: Increased this // josh: TODO: tjw? What is this desc thing for? char desc[115]; int age; int eff_XPSaveMaxAge_xp = G_getXPSaveMaxAge_xp(); int eff_XPSaveMaxAge = G_getXPSaveMaxAge(); float startxptotal = 0.0f; if(!ent || !ent->client) return qfalse; if(!(g_XPSave.integer & XPSF_ENABLE)) return qfalse; if(!time(&t)) return qfalse; desc[0] = '/0'; clientNum = ent - g_entities; for(i=0; g_xpsaves[i]; i++) { if(!Q_stricmp(g_xpsaves[i]->guid, ent->client->sess.guid)) { found = qtrue; x = g_xpsaves[i]; break; } } if(!found) return qfalse; age = t - x->time; if(age > eff_XPSaveMaxAge) { return qfalse; } if(age <= eff_XPSaveMaxAge_xp) { for(i=0; i<SK_NUM_SKILLS; i++) { ent->client->sess.skillpoints[i] = x->skill[i]; // pheno: fix for session startxptotal value startxptotal += x->skill[i]; } ent->client->sess.startxptotal = startxptotal; ent->client->ps.stats[STAT_XP] = (int)ent->client->sess.startxptotal; Q_strcat(desc, sizeof(desc), "XP/"); if((g_XPDecay.integer & XPDF_ENABLE) && !(g_XPDecay.integer & XPDF_NO_DISCONNECT_DECAY)) { G_XPDecay(ent, age, qtrue); } } ent->client->sess.overall_killrating = x->kill_rating; ent->client->sess.overall_killvariance = x->kill_variance; //ent->client->sess.playerrating = x->playerrating; ent->client->sess.rating = x->rating; ent->client->sess.rating_variance = x->rating_variance; for(i=0; i<SK_NUM_SKILLS; i++) { for(j=0; j<NUM_SKILL_LEVELS; j++) { ent->client->sess.pr_skill_updates[i][j] = x->pr_skill_updates[i][j]; ent->client->sess.pr_skill[i][j] = x->pr_skill[i][j]; } } Q_strcat(desc, sizeof(desc), "ratings/"); if(x->mutetime != 0) { if(x->mutetime < 0){ ent->client->sess.auto_unmute_time = -1; XPSMuted = qtrue; }else if(x->mutetime > t){ ent->client->sess.auto_unmute_time = (level.time + 1000*(x->mutetime - t)); XPSMuted = qtrue;; } if(XPSMuted == qtrue){ CP("print /"^5You've been muted by XPSave/n/"" ); Q_strcat(desc, sizeof(desc), "mute/"); } } ent->client->sess.hits = x->hits; ent->client->sess.team_hits = x->team_hits; G_CalcRank(ent->client); BG_PlayerStateToEntityState(&ent->client->ps, &ent->s, level.time, qtrue); // tjw: trim last / from desc if(strlen(desc))//.........这里部分代码省略.........
开发者ID:BulldogDrummond,项目名称:etpub,代码行数:101,
示例2: CPhttp_header& http_header::set_host(const char* value){ if (value && *value) CP(host_, value); return *this;}
开发者ID:10jschen,项目名称:acl,代码行数:6,
示例3: Cmd_Powerup_fvoid Cmd_Powerup_f( gentity_t * ent ) { int i = 0; int argc = trap_Argc(); char arg[MAX_TOKEN_CHARS] = "/0"; char arg2[MAX_TOKEN_CHARS] = "/0"; if( !ent->client->sess.routeMaker ) { CP("cp /"^7You need to be a route maker to create powerups./n/""); return; } if(argc < 2) { CP("print /"usage: ^7powerup [type]/n/""); return; } trap_Argv(1, arg, sizeof(arg)); if(!Q_stricmp(arg, "help")) { PrintPowerupHelp(ent); return; } if(!Q_stricmp(arg, "info")) { trap_Argv(2, arg, sizeof(arg)); PrintPowerupInfo(ent, arg); return; } // Special case, spawn random pwup if(!Q_stricmp(arg, "random")) { int index = rand() % numPowerups; if(powerups[index].spawn && powerups[index].think) { if(level.numPowerups == MAX_POWERUPS) { CP("print /"^1error: ^7too many powerups spawned./n/""); return; } level.powerups[level.numPowerups] = powerups[index].spawn(ent, powerups[index].think); level.powerups[level.numPowerups]->powerupType = powerups[index].pw; level.powerups[level.numPowerups]->powerupModelType = powerups[index].modelIndex; level.numPowerups++; CP("cp /"^5Spawned a random powerup/n/""); } return; } if(!Q_stricmp(arg, "any")) { if(level.numPowerups == MAX_POWERUPS) { CP("print /"^1error: ^7too many powerups spawned./n/""); return; } level.powerups[level.numPowerups] = SpawnRandomPowerupSpawner( ent ); level.powerups[level.numPowerups]->powerupType = PW_RANDOM; level.powerups[level.numPowerups]->powerupModelType = PW_RANDOM; level.numPowerups++; CP("cp /"^5Spawned a random powerup/n/""); return; } for(; i < numPowerups; i++) { if(!Q_stricmp(arg, powerups[i].name)) { if(powerups[i].spawn && powerups[i].think) { if(level.numPowerups == MAX_POWERUPS) { CP("print /"^1error: ^7too many powerups spawned./n/""); return; } level.powerups[level.numPowerups] = powerups[i].spawn(ent, powerups[i].think); level.powerups[level.numPowerups]->powerupType = powerups[i].pw; level.powerups[level.numPowerups]->powerupModelType = powerups[i].modelIndex; level.numPowerups++; CP(va("cp /"^5Spawned a %s powerup/n/"", powerups[i].text)); } else { G_LogPrintf("Undefined powerup: %s/n", arg); } break; } }}
开发者ID:haapanen,项目名称:satchelrace,代码行数:95,
示例4: cm_t35_set_muxconfstatic void cm_t35_set_muxconf(void){ /* DSS */ MUX_VAL(CP(DSS_DATA0), (IDIS | PTD | DIS | M0)); /*DSS_DATA0*/ MUX_VAL(CP(DSS_DATA1), (IDIS | PTD | DIS | M0)); /*DSS_DATA1*/ MUX_VAL(CP(DSS_DATA2), (IDIS | PTD | DIS | M0)); /*DSS_DATA2*/ MUX_VAL(CP(DSS_DATA3), (IDIS | PTD | DIS | M0)); /*DSS_DATA3*/ MUX_VAL(CP(DSS_DATA4), (IDIS | PTD | DIS | M0)); /*DSS_DATA4*/ MUX_VAL(CP(DSS_DATA5), (IDIS | PTD | DIS | M0)); /*DSS_DATA5*/ MUX_VAL(CP(DSS_DATA18), (IDIS | PTD | DIS | M0)); /*DSS_DATA18*/ MUX_VAL(CP(DSS_DATA19), (IDIS | PTD | DIS | M0)); /*DSS_DATA19*/ MUX_VAL(CP(DSS_DATA20), (IDIS | PTD | DIS | M0)); /*DSS_DATA20*/ MUX_VAL(CP(DSS_DATA21), (IDIS | PTD | DIS | M0)); /*DSS_DATA21*/ MUX_VAL(CP(DSS_DATA22), (IDIS | PTD | DIS | M0)); /*DSS_DATA22*/ MUX_VAL(CP(DSS_DATA23), (IDIS | PTD | DIS | M0)); /*DSS_DATA23*/ /* MMC1 */ MUX_VAL(CP(MMC1_DAT4), (IEN | PTU | EN | M0)); /*MMC1_DAT4*/ MUX_VAL(CP(MMC1_DAT5), (IEN | PTU | EN | M0)); /*MMC1_DAT5*/ MUX_VAL(CP(MMC1_DAT6), (IEN | PTU | EN | M0)); /*MMC1_DAT6*/ MUX_VAL(CP(MMC1_DAT7), (IEN | PTU | EN | M0)); /*MMC1_DAT7*/}
开发者ID:5victor,项目名称:u-boot-mini2440,代码行数:23,
示例5: G_voteHelp// Voting help summary.void G_voteHelp(gentity_t *ent, qboolean fShowVote){ int i, rows = 0, num_cmds = sizeof(aVoteInfo) / sizeof(aVoteInfo[0]) - 1; // Remove terminator; int vi[100]; // Just make it large static. if (fShowVote) { CP("print /"/nValid ^3callvote^7 commands are:/n^3----------------------------/n/""); } for (i = 0; i < num_cmds; i++) { if (aVoteInfo[i].dwGameTypes & (1 << g_gametype.integer)) { vi[rows++] = i; } } num_cmds = rows; rows = num_cmds / HELP_COLUMNS; if (num_cmds % HELP_COLUMNS) { rows++; } if (rows < 0) { return; } for (i = 0; i < rows; i++) { if (i + rows * 3 + 1 <= num_cmds) { G_refPrintf(ent, "^5%-17s%-17s%-17s%-17s", aVoteInfo[vi[i]].pszVoteName, aVoteInfo[vi[i + rows]].pszVoteName, aVoteInfo[vi[i + rows * 2]].pszVoteName, aVoteInfo[vi[i + rows * 3]].pszVoteName); } else if (i + rows * 2 + 1 <= num_cmds) { G_refPrintf(ent, "^5%-17s%-17s%-17s", aVoteInfo[vi[i]].pszVoteName, aVoteInfo[vi[i + rows]].pszVoteName, aVoteInfo[vi[i + rows * 2]].pszVoteName); } else if (i + rows + 1 <= num_cmds) { G_refPrintf(ent, "^5%-17s%-17s", aVoteInfo[vi[i]].pszVoteName, aVoteInfo[vi[i + rows]].pszVoteName); } else { G_refPrintf(ent, "^5%-17s", aVoteInfo[vi[i]].pszVoteName); } } if (fShowVote) { CP("print /"/nUsage: ^3//callvote <command> <params>/n^7For current settings/help, use: ^3//callvote <command> ?/n/n/""); } return;}
开发者ID:morsik,项目名称:war-territory,代码行数:65,
示例6: G_smvAddView// Add a player entity to another player's multiview listvoid G_smvAddView(gentity_t *ent, int pID){ int i; mview_t *mv = NULL; gentity_t *v; if (pID >= MAX_MVCLIENTS || G_smvLocateEntityInMVList(ent, pID, qfalse)) { return; } for (i = 0; i < MULTIVIEW_MAXVIEWS; i++) { if (!ent->client->pers.mv[i].fActive) { mv = &ent->client->pers.mv[i]; break; } } if (mv == NULL) { CP(va("print /"[lof]** [lon]Sorry, no more MV slots available (all[lof] %d [lon]in use)[lof]/n/"", MULTIVIEW_MAXVIEWS)); return; } mv->camera = G_Spawn(); if (mv->camera == NULL) { return; } if (ent->client->sess.sessionTeam == TEAM_SPECTATOR && /*ent->client->sess.sessionTeam != TEAM_SPECTATOR ||*/ ent->client->sess.spectatorState == SPECTATOR_FOLLOW) { SetTeam(ent, "s", qtrue, -1, -1, qfalse); } else if (ent->client->sess.sessionTeam != TEAM_SPECTATOR && !(ent->client->ps.pm_flags & PMF_LIMBO)) { limbo(ent, qtrue); } ent->client->ps.clientNum = ent - g_entities; ent->client->sess.spectatorState = SPECTATOR_FREE; ent->client->pers.mvCount++; mv->fActive = qtrue; mv->entID = pID; v = mv->camera; v->classname = "misc_portal_surface"; v->r.svFlags = SVF_PORTAL | SVF_SINGLECLIENT; // Only merge snapshots for the target client v->r.singleClient = ent->s.number; v->s.eType = ET_PORTAL; VectorClear(v->r.mins); VectorClear(v->r.maxs); trap_LinkEntity(v); v->target_ent = &g_entities[pID]; v->TargetFlag = pID; v->tagParent = ent; G_smvUpdateClientCSList(ent);}
开发者ID:Classixz,项目名称:etlegacy,代码行数:66,
示例7: G_players_cmd// ************** PLAYERS//// Show client infovoid G_players_cmd(gentity_t *ent, unsigned int dwCommand, qboolean fValue){ int i, idnum, max_rate, cnt=0, tteam; int user_rate, user_snaps, bots = 0; gclient_t *cl; gentity_t *cl_ent; char n2[MAX_NETNAME], ready[16], ref[16], ign[16], rate[256]; char *s, *tc, *coach, userinfo[MAX_INFO_STRING]; if(g_gamestate.integer == GS_PLAYING) { if(ent) { CP("print /"/n^3 ID^1 : ^3Player Nudge Rate MaxPkts Snaps/n/""); CP( "print /"^1-----------------------------------------------------------^7/n/""); } else { G_Printf(" ID : Player Nudge Rate MaxPkts Snaps/n"); G_Printf("-----------------------------------------------------------/n"); } } else { if(ent) { CP("print /"/n^3Status^1 : ^3ID^1 : ^3Player Nudge Rate MaxPkts Snaps/n/""); CP( "print /"^1---------------------------------------------------------------------^7/n/""); } else { G_Printf("Status : ID : Player Nudge Rate MaxPkts Snaps/n"); G_Printf("---------------------------------------------------------------------/n"); } } max_rate = trap_Cvar_VariableIntegerValue("sv_maxrate"); for(i=0; i<level.numConnectedClients; i++) { idnum = level.sortedClients[i];//level.sortedNames[i]; cl = &level.clients[idnum]; cl_ent = g_entities + idnum; SanitizeString(cl->pers.netname, n2, qtrue); n2[26] = 0; ref[0] = 0; ign[0] = 0; ready[0] = 0; // Rate info if(cl_ent->r.svFlags & SVF_BOT) { strcpy(rate, va("%s%s%s%s", "[BOT]", " -----", " --", " --")); bots++; } else if(cl->pers.connected == CON_CONNECTING) { strcpy(rate, va("%s", "^3>>> CONNECTING <<<")); } else { trap_GetUserinfo( idnum, userinfo, sizeof(userinfo)); s = Info_ValueForKey( userinfo, "rate" ); user_rate = (max_rate > 0 && atoi(s) > max_rate) ? max_rate : atoi(s); s = Info_ValueForKey( userinfo, "snaps" ); user_snaps = atoi(s); strcpy(rate, va("%5d%6d%9d%7d", cl->pers.clientTimeNudge, user_rate, cl->pers.clientMaxPackets, user_snaps)); } if(g_gamestate.integer != GS_PLAYING) { // Dens: bots aren't counted, but specs are since changeset 1469 if((g_entities[idnum].r.svFlags & SVF_BOT) || cl->pers.connected == CON_CONNECTING) strcpy(ready, ((ent) ? "^5--------^1 :" : "-------- :")); else if(cl->pers.ready) strcpy(ready, ((ent) ? "^3(READY)^1 :" : "(READY) :")); else strcpy(ready, ((ent) ? "NOTREADY^1 :" : "NOTREADY :")); } if(cl->sess.referee) strcpy(ref, "REF "); // pheno: mark ignored clients if ( COM_BitCheck(ent->client->sess.ignoreClients, idnum) ) { strcpy(ign, (( ent ) ? "^8I" : "I")); } if(cl->sess.coach_team) { tteam = cl->sess.coach_team; coach = (ent) ? "^3C" : "C"; } else { tteam = cl->sess.sessionTeam; coach = " "; } tc = (ent) ? "^7 " : " "; if(g_gametype.integer >= GT_WOLF) { if(tteam == TEAM_AXIS) tc = (ent) ? "^1X^7" : "X"; if(tteam == TEAM_ALLIES) tc = (ent) ? "^4L^7" : "L"; } if(ent) CP(va("print /"%s%s%2d%s^1:%s %-26s^7%s ^3%s%s/n/"", ready, tc, idnum, coach, ((ref[0])?"^3":"^7"), n2, rate, ref, ign)); else G_Printf("%s%s%2d%s: %-26s%s %s%s/n", ready, tc, idnum, coach, n2, rate, ref, ign); cnt++; } if(ent) CP(va("print /"/n^3%2d^7 total players (^3%2d^7 humans, ^3%2d^7 bots)/n/n/"", cnt, cnt - bots, bots)); else G_Printf("/n%2d total players (%2d humans, %2d bots/n/n", cnt, cnt - bots, bots);//.........这里部分代码省略.........
开发者ID:BulldogDrummond,项目名称:etpub,代码行数:101,
示例8: getargs/* * Get the argument words for a command into genbuf * expanding # and %. */intgetargs(void){ register int c; register char *cp, *fp; static char fpatbuf[32]; /* hence limit on :next +/pat */ pastwh(); if (peekchar() == '+') { for (cp = fpatbuf;;) { c = *cp++ = ex_getchar(); if (cp >= &fpatbuf[sizeof(fpatbuf)]) error("Pattern too long"); if (c == '//' && isspace(peekchar())) c = ex_getchar(); if (c == EOF || isspace(c)) { ungetchar(c); *--cp = 0; firstpat = &fpatbuf[1]; break; } } } if (skipend()) return (0); CP(genbuf, "echo "); cp = &genbuf[5]; for (;;) { c = ex_getchar(); if (endcmd(c)) { ungetchar(c); break; } switch (c) { case '//': if (any(peekchar(), "#%|")) c = ex_getchar(); /* fall into... */ default: if (cp > &genbuf[LBSIZE - 2])flong: error("Argument buffer overflow"); *cp++ = c; break; case '#': fp = altfile; if (*fp == 0) error("No alternate file[email C++ CPACC_FULL函数代码示例 C++ COutPoint函数代码示例
|