void ContactManager::AddPair(Fixture *A, Fixture *B) { Vector2 pt, norml; float sep; if ( FindOverlap(A->GetShape(), A->GetBody()->position, B->GetShape(), B->GetBody()->position, norml, pt, sep) ) { assert( A->GetBody() != B->GetBody() ); contacts[numContacts] = Contact(A, B, norml, pt, sep); numContacts++; assert(numContacts < MaxNumContacts); } }
int main() { int n, i, k, j, max_overlap, overlap, index1 = 0, index2 = 0; char** data; char* result = NULL; scanf("%d", &n); data = (char**)malloc(n*sizeof(char*)); for (i = 0; i < n; i++) { data[i] = (char*)malloc(1024*sizeof(char)); scanf("%s", data[i]); } for (k = 0; k < n; k++) { max_overlap = -1; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { if (i == j) continue; overlap = FindOverlap(data[i], data[j]); if (overlap > max_overlap) { max_overlap = overlap; index1 = i; index2 = j; } } } if (max_overlap >= 0) { data[index1][strlen(data[index1]) - max_overlap] = '\0'; strcat(data[index1], data[index2]); data[index2][0] = '\0'; result = data[index1]; } } printf("%lu\n", strlen(result)); for (i = 0; i < n; i++) { free(data[i]); } free(data); return 0; }
/* ================= ClientEndServerFrame Called for each player at the end of the server frame and right after spawning ================= */ void ClientEndServerFrame (edict_t * ent) { float bobtime; int i; //char player_name[30]; //char temp[40]; // int damage; // zucc for bleeding current_player = ent; current_client = ent->client; //AQ2:TNG - Slicer : Stuffs the client x seconds after he enters the server, needed for Video check if (ent->client->resp.checktime[0] <= level.time) { ent->client->resp.checktime[0] = level.time + video_checktime->value; if (video_check->value || video_check_lockpvs->value || video_check_glclear->value || darkmatch->value) stuffcmd (ent, "%!fc $vid_ref\n"); if (video_force_restart->value && video_check->value && !ent->client->resp.checked) { stuffcmd (ent, "vid_restart\n"); ent->client->resp.checked = true; } } if (ent->client->resp.checktime[1] <= level.time) { ent->client->resp.checktime[1] = level.time + video_checktime->value; ent->client->resp.checktime[2] = level.time + 1; if (video_check->value || video_check_lockpvs->value || video_check_glclear->value || darkmatch->value) { if (ent->client->resp.vidref && Q_stricmp(ent->client->resp.vidref, "soft")) stuffcmd (ent, "%cpsi $gl_modulate $gl_lockpvs $gl_clear $gl_dynamic $gl_driver\n"); } } if (ent->client->resp.checktime[2] <= level.time) { // ent->client->resp.checktime[2] = level.time + video_checktime->value; if (video_check->value || video_check_lockpvs->value || video_check_glclear->value || darkmatch->value) { if (ent->client->resp.vidref && Q_stricmp(ent->client->resp.vidref, "soft")) VideoCheckClient (ent); } } if(pause_time) { G_SetStats (ent); return; } //FIREBLADE - Unstick avoidance stuff. if (ent->solid == SOLID_TRIGGER && !lights_camera_action) { edict_t *overlap; if ((overlap = FindOverlap (ent, NULL)) == NULL) { ent->solid = SOLID_BBOX; gi.linkentity (ent); RemoveFromTransparentList (ent); } else { do { if (overlap->solid == SOLID_BBOX) { overlap->solid = SOLID_TRIGGER; gi.linkentity (overlap); AddToTransparentList (overlap); } overlap = FindOverlap (ent, overlap); } while (overlap != NULL); } } //FIREBLADE // // If the origin or velocity have changed since ClientThink(), // update the pmove values. This will happen when the client // is pushed by a bmodel or kicked by an explosion. // // If it wasn't updated here, the view position would lag a frame // behind the body position when pushed -- "sinking into plats" // for (i = 0; i < 3; i++) { current_client->ps.pmove.origin[i] = ent->s.origin[i] * 8.0; current_client->ps.pmove.velocity[i] = ent->velocity[i] * 8.0; } // // If the end of unit layout is displayed, don't give // the player any normal movement attributes // if (level.intermissiontime) { // FIXME: add view drifting here? current_client->ps.blend[3] = 0; current_client->ps.fov = 90; G_SetStats (ent); return; } AngleVectors (ent->client->v_angle, forward, right, up); // burn from lava, etc P_WorldEffects (); // // set model angles from view angles so other things in // the world can tell which direction you are looking // if (ent->client->v_angle[PITCH] > 180) ent->s.angles[PITCH] = (-360 + ent->client->v_angle[PITCH]) / 3; else ent->s.angles[PITCH] = ent->client->v_angle[PITCH] / 3; ent->s.angles[YAW] = ent->client->v_angle[YAW]; ent->s.angles[ROLL] = 0; ent->s.angles[ROLL] = SV_CalcRoll (ent->s.angles, ent->velocity) * 4; // // calculate speed and cycle to be used for // all cyclic walking effects // xyspeed = sqrt(ent->velocity[0]*ent->velocity[0] + ent->velocity[1]*ent->velocity[1]); if (xyspeed < 5 || ent->solid == SOLID_NOT) { bobmove = 0; current_client->bobtime = 0; // start at beginning of cycle again } else if (ent->groundentity) { // so bobbing only cycles when on ground if (xyspeed > 210) bobmove = 0.25; else if (xyspeed > 100) bobmove = 0.125; else bobmove = 0.0625; } bobtime = (current_client->bobtime += bobmove); if (current_client->ps.pmove.pm_flags & PMF_DUCKED) bobtime *= 4; bobcycle = (int) bobtime; bobfracsin = fabs (sin (bobtime * M_PI)); // detect hitting the floor P_FallingDamage (ent); // zucc handle any bleeding damage here Do_Bleeding (ent); // apply all the damage taken this frame P_DamageFeedback (ent); // determine the view offsets SV_CalcViewOffset (ent); // determine the gun offsets SV_CalcGunOffset (ent); // determine the full screen color blend // must be after viewoffset, so eye contents can be // accurately determined // FIXME: with client prediction, the contents // should be determined by the client SV_CalcBlend (ent); G_SetStats (ent); //FIREBLADE for (i = 1; i <= maxclients->value; i++) { int stats_copy; edict_t *e = g_edicts + i; if (!ent->inuse || e->client->chase_mode == 0 || e->client->chase_target != ent) continue; for (stats_copy = 0; stats_copy < MAX_STATS; stats_copy++) { if (stats_copy >= STAT_TEAM_HEADER && stats_copy <= STAT_TEAM2_SCORE) continue; // protect these if (stats_copy >= STAT_TEAM3_PIC && stats_copy <= STAT_TEAM3_SCORE) continue; // protect these if (stats_copy == STAT_LAYOUTS || stats_copy == STAT_ID_VIEW) continue; // protect these if (stats_copy == STAT_SNIPER_ICON && e->client->chase_mode != 2) continue; // only show sniper lens when in chase mode 2 if (stats_copy == STAT_FRAGS) continue; e->client->ps.stats[stats_copy] = ent->client->ps.stats[stats_copy]; } //FB e->client->ps.stats[STAT_LAYOUTS] = 1; //FB break; } //FIREBLADE G_SetClientEvent (ent); G_SetClientEffects (ent); G_SetClientSound (ent); G_SetClientFrame (ent); VectorCopy (ent->velocity, ent->client->oldvelocity); VectorCopy (ent->client->ps.viewangles, ent->client->oldviewangles); // clear weapon kicks VectorClear (ent->client->kick_origin); VectorClear (ent->client->kick_angles); // zucc - clear the open door command ent->client->doortoggle = 0; if (ent->client->push_timeout > 0) ent->client->push_timeout--; /* else { ent->client->attacker = NULL; ent->client->attacker_mod = MOD_BLEEDING; } */ if (ent->client->reload_attempts > 0) { if (((ent->client->latched_buttons | ent->client->buttons) & BUTTON_ATTACK) && canFire(ent)) { ent->client->reload_attempts = 0; } else { Cmd_Reload_f (ent); } } if (ent->client->weapon_attempts > 0) Cmd_Weapon_f (ent); // if the scoreboard is up, update it if (ent->client->showscores && !(level.framenum & 31)) { //FIREBLADE if (ent->client->menu) { PMenu_Update (ent); } else //FIREBLADE DeathmatchScoreboardMessage (ent, ent->enemy); gi.unicast (ent, false); } //FIREBLADE if(!pause_time) RadioThink (ent); //FIREBLADE }