void SnapPlane( vec3_t normal, vec_t *dist, vec3_t center ) { // SnapPlane disabled by LordHavoc because it often messes up collision // brushes made from triangles of embedded models, and it has little effect // on anything else (axial planes are usually derived from snapped points) /* SnapPlane reenabled by namespace because of multiple reports of q3map2-crashes which were triggered by this patch. */ SnapNormal( normal ); // TODO: Rambetter has some serious comments here as well. First off, // in the case where a normal is non-axial, there is nothing special // about integer distances. I would think that snapping a distance might // make sense for axial normals, but I'm not so sure about snapping // non-axial normals. A shift by 0.01 in a plane, multiplied by a clipping // against another plane that is 5 degrees off, and we introduce 0.1 error // easily. A 0.1 error in a vertex is where problems start to happen, such // as disappearing triangles. // Second, assuming we have snapped the normal above, let's say that the // plane we just snapped was defined for some points that are actually // quite far away from normal * dist. Well, snapping the normal in this // case means that we've just moved those points by potentially many units! // Therefore, if we are going to snap the normal, we need to know the // points we're snapping for so that the plane snaps with those points in // mind (points remain close to the plane). // I would like to know exactly which problems SnapPlane() is trying to // solve so that we can better engineer it (I'm not saying that SnapPlane() // should be removed altogether). Fix all this snapping code at some point! if( fabs( *dist - Q_rint( *dist ) ) < distanceEpsilon ) *dist = Q_rint( *dist ); }
/* ============== SnapPlane ============== */ void SnapPlane (vec3_t normal, vec_t *dist) { SnapVector (normal); if (fabs(*dist-Q_rint(*dist)) < DIST_EPSILON) *dist = Q_rint(*dist); }
/* ================= SnapPlane snaps a plane to normal/distance epsilons ================= */ void SnapPlane( vec3_t normal, vec_t *dist ) { SnapNormal( normal ); if( fabs( *dist - Q_rint( *dist )) < distanceEpsilon ) *dist = Q_rint( *dist ); }
// // Scrollbar - Mouse event. // int EZ_scrollbar_OnMouseEvent(ez_control_t *self, mouse_state_t *ms) { ez_scrollbar_t *scrollbar = (ez_scrollbar_t *)self; ez_control_t *back_ctrl = (ez_control_t *)scrollbar->back; ez_control_t *forward_ctrl = (ez_control_t *)scrollbar->forward; ez_control_t *slider_ctrl = (ez_control_t *)scrollbar->slider; int m_delta_x = Q_rint(ms->x - ms->x_old); int m_delta_y = Q_rint(ms->y - ms->y_old); qbool mouse_handled = false; qbool mouse_handled_tmp = false; mouse_handled = EZ_control_OnMouseEvent(self, ms); if (!mouse_handled) { if (scrollbar->int_flags & sliding) { if (scrollbar->orientation == vertical) { // float scroll_ratio = 0; // Reposition the slider within the scrollbar control based on where the mouse moves. int new_y = slider_ctrl->y + m_delta_y; // Only allow moving the scroll slider in the area between the two buttons (the scroll area). clamp(new_y, back_ctrl->height, (self->height - forward_ctrl->height - slider_ctrl->height)); EZ_control_SetPosition(slider_ctrl, 0, new_y); mouse_handled = true; } else { int new_x = slider_ctrl->x + m_delta_x; clamp(new_x, back_ctrl->width, (self->width - forward_ctrl->width - slider_ctrl->width)); EZ_control_SetPosition(slider_ctrl, new_x, 0); mouse_handled = true; } // Make sure we don't try to set the position of the slider // as the parents scroll position changes, like normal. scrollbar->int_flags |= scrolling; if (scrollbar->ext_flags & target_parent) { EZ_scrollbar_CalculateParentScrollPosition(scrollbar, self->parent); } else { EZ_scrollbar_CalculateParentScrollPosition(scrollbar, scrollbar->target); } scrollbar->int_flags &= ~scrolling; } } CONTROL_EVENT_HANDLER_CALL(&mouse_handled_tmp, self, ez_control_t, OnMouseEvent, ms); mouse_handled = (mouse_handled | mouse_handled_tmp); return mouse_handled; }
void WriteFloat (FILE *f, vec_t v) { if ( fabs(v - Q_rint(v)) < 0.001 ) fprintf (f,"%i ",(int)Q_rint(v)); else fprintf (f,"%f ",v); }
static void WriteFloat(vec_t v) { if (fabs(v - Q_rint(v)) < ZERO_EPSILON) fprintf(PortalFile, "%i ", (int)Q_rint(v)); else fprintf(PortalFile, "%f ", v); }
/* * Cvar_SetValue * Expands value to a string and calls Cvar_Set */ void Cvar_SetValue( const char *var_name, float value ) { char val[32]; if( value == Q_rint( value ) ) Q_snprintfz( val, sizeof( val ), "%i", Q_rint( value ) ); else Q_snprintfz( val, sizeof( val ), "%f", value ); Cvar_Set( var_name, val ); }
// // Slider - Draw function for the slider. // int EZ_slider_OnDraw(ez_control_t *self, void *ext_event_info) { int x, y, i; ez_slider_t *slider = (ez_slider_t *)self; EZ_control_GetDrawingPosition(self, &x, &y); // Draw the background. { // Left edge. Draw_SCharacter(x, y, 128, slider->scale); for (i = 1; i < Q_rint((float)(self->width - slider->scaled_char_size) / slider->scaled_char_size); i++) { Draw_SCharacter(x + (i * slider->scaled_char_size), y, 129, slider->scale); } // Right edge. Draw_SCharacter(x + (i * slider->scaled_char_size), y, 130, slider->scale); } // Slider. Draw_SCharacter(x + slider->real_slider_pos, y, 131, slider->scale); return 0; }
/* ============= Fog_GetColor calculates fog color for this frame, taking into account fade times ============= */ float *Fog_GetColor (void) { static float c[4]; float f; int i; if (fade_done > cl.time) { f = (fade_done - cl.time) / fade_time; c[0] = f * old_red + (1.0 - f) * fog_red; c[1] = f * old_green + (1.0 - f) * fog_green; c[2] = f * old_blue + (1.0 - f) * fog_blue; c[3] = 1.0; } else { c[0] = fog_red; c[1] = fog_green; c[2] = fog_blue; c[3] = 1.0; } //find closest 24-bit RGB value, so solid-colored sky can match the fog perfectly for (i=0;i<3;i++) c[i] = (float)(Q_rint(c[i] * 255)) / 255.0f; return c; }
/* SnapPlaneImproved() snaps a plane to normal/distance epsilons, improved code */ void SnapPlaneImproved(vec3_t normal, vec_t *dist, int numPoints, const vec3_t *points) { int i; vec3_t center; vec_t distNearestInt; if (SnapNormal(normal)) { if (numPoints > 0) { // Adjust the dist so that the provided points don't drift away. VectorClear(center); for (i = 0; i < numPoints; i++) { VectorAdd(center, points[i], center); } for (i = 0; i < 3; i++) { center[i] = center[i] / numPoints; } *dist = DotProduct(normal, center); } } if (VectorIsOnAxis(normal)) { // Only snap distance if the normal is an axis. Otherwise there // is nothing "natural" about snapping the distance to an integer. distNearestInt = Q_rint(*dist); if (-distanceEpsilon < *dist - distNearestInt && *dist - distNearestInt < distanceEpsilon) { *dist = distNearestInt; } } }
// // Slider - Handles a mouse event. // int EZ_slider_OnMouseEvent(ez_control_t *self, mouse_state_t *ms) { // Make sure we handle all mouse events when we're over the control // otherwise they will fall through to controls below. int mouse_handled = POINT_IN_CONTROL_RECT(self, ms->x, ms->y); ez_slider_t *slider = (ez_slider_t *)self; // Call the super class first. EZ_control_OnMouseEvent(self, ms); if (slider->int_flags & slider_dragging) { int new_slider_pos = slider->min_value + Q_rint((ms->x - self->absolute_x) / slider->gap_size); EZ_slider_SetPosition(slider, new_slider_pos); mouse_handled = true; } // Event handler call. { int mouse_handled_tmp = false; CONTROL_EVENT_HANDLER_CALL(&mouse_handled_tmp, self, ez_control_t, OnMouseEvent, ms); mouse_handled = (mouse_handled || mouse_handled_tmp); } return mouse_handled; }
/* * Cvar_GetLatchedVars * * Any variables with CVAR_LATCHED will now be updated */ void Cvar_GetLatchedVars( cvar_flag_t flags ) { unsigned int i; struct trie_dump_s *dump; cvar_flag_t latchFlags; Cvar_FlagsClear( &latchFlags ); Cvar_FlagSet( &latchFlags, CVAR_LATCH ); Cvar_FlagSet( &latchFlags, CVAR_LATCH_VIDEO ); Cvar_FlagSet( &latchFlags, CVAR_LATCH_SOUND ); Cvar_FlagUnset( &flags, ~latchFlags ); if( !flags ) return; assert( cvar_trie ); Trie_DumpIf( cvar_trie, "", TRIE_DUMP_VALUES, Cvar_IsLatched, &flags, &dump ); for( i = 0; i < dump->size; ++i ) { cvar_t *const var = (cvar_t *) dump->key_value_vector[i].value; if( !strcmp( var->name, "fs_game" ) ) { FS_SetGameDirectory( var->latched_string, qfalse ); return; } Mem_ZoneFree( var->string ); var->string = var->latched_string; var->latched_string = NULL; var->value = atof( var->string ); var->integer = Q_rint( var->value ); } Trie_FreeDump( dump ); }
/* ============= GetVertex ============= */ static int GetVertex(mapentity_t *entity, const vec3_t in) { int h; int i; hashvert_t *hv; vec3_t vert; struct lumpdata *vertices = &entity->lumps[LUMP_VERTEXES]; dvertex_t *dvertex; for (i = 0; i < 3; i++) { if (fabs(in[i] - Q_rint(in[i])) < ZERO_EPSILON) vert[i] = Q_rint(in[i]); else vert[i] = in[i]; } h = HashVec(vert); for (hv = hashverts[h]; hv; hv = hv->next) { if (fabs(hv->point[0] - vert[0]) < POINT_EPSILON && fabs(hv->point[1] - vert[1]) < POINT_EPSILON && fabs(hv->point[2] - vert[2]) < POINT_EPSILON) { hv->numedges++; return hv->num; } } hv = hvert_p++; hv->num = map.cTotal[LUMP_VERTEXES]++; hv->numedges = 1; hv->next = hashverts[h]; hashverts[h] = hv; VectorCopy(vert, hv->point); if (vertices->index == vertices->count) Error("Internal error: didn't allocate enough vertices?"); /* emit a vertex */ dvertex = (dvertex_t *)vertices->data + vertices->index; dvertex->point[0] = vert[0]; dvertex->point[1] = vert[1]; dvertex->point[2] = vert[2]; vertices->index++; return hv->num; }
// // Slider - Calculates the actual slider position. // __inline void EZ_slider_CalculateRealSliderPos(ez_slider_t *slider) { int pos = slider->slider_pos - slider->min_value; // Calculate the real position of the slider by multiplying by the gap size between each value. // (Don't start drawing at the exact start cause that would overwrite the edge marker) slider->real_slider_pos = Q_rint((slider->scaled_char_size / 2.0) + (pos * slider->gap_size)); }
qboolean Movie_GetSoundtime (void) { if (!Movie_IsActive()) return false; soundtime += Q_rint (host_frametime * shm->speed * (Movie_FrameTime() / host_frametime)); return true; }
/* =================== S_UpdateAmbientSounds =================== */ void S_UpdateAmbientSounds (void) { struct cleaf_s *leaf; float vol; int ambient_channel; channel_t *chan; if (cls.state != ca_active) return; leaf = CM_PointInLeaf (listener_origin); if (!CM_Leafnum(leaf) || !s_ambientlevel.value) { for (ambient_channel = 0 ; ambient_channel< NUM_AMBIENTS ; ambient_channel++) channels[ambient_channel].sfx = NULL; return; } for (ambient_channel = 0; ambient_channel < NUM_AMBIENTS; ambient_channel++) { chan = &channels[ambient_channel]; chan->sfx = ambient_sfx[ambient_channel]; vol = s_ambientlevel.value * CM_LeafAmbientLevel(leaf, ambient_channel); if (vol < 8) vol = 0; // don't adjust volume too fast if (chan->master_vol < vol) { chan->master_vol += Q_rint(cls.frametime * s_ambientfade.value); if (chan->master_vol > vol) chan->master_vol = vol; } else if (chan->master_vol > vol) { chan->master_vol -= Q_rint(cls.frametime * s_ambientfade.value); if (chan->master_vol < vol) chan->master_vol = vol; } chan->leftvol = chan->rightvol = chan->master_vol; } }
// // Scrollbar - Updates the slider position of the scrollbar based on the parents scroll position. // static void EZ_scrollbar_UpdateSliderBasedOnTarget(ez_scrollbar_t *scrollbar, ez_control_t *target) { ez_control_t *self = (ez_control_t *)scrollbar; ez_control_t *back_ctrl = (ez_control_t *)scrollbar->back; ez_control_t *forward_ctrl = (ez_control_t *)scrollbar->forward; ez_control_t *slider_ctrl = (ez_control_t *)scrollbar->slider; float scroll_ratio; if (!target) { return; } // Don't do anything if this is the user moving the slider using the mouse. if (scrollbar->int_flags & scrolling) { return; } if (scrollbar->orientation == vertical) { int new_y; // Find how far down on the parent control we're scrolled (percentage). scroll_ratio = fabs(target->virtual_y / (float)target->virtual_height); // Calculate the position of the slider by multiplying the scroll areas // height with the scroll ratio. new_y = back_ctrl->height + Q_rint(scroll_ratio * scrollbar->scroll_area); clamp(new_y, back_ctrl->height, (self->height - forward_ctrl->height - slider_ctrl->height)); EZ_control_SetPosition(slider_ctrl, 0, new_y); } else { int new_x; scroll_ratio = fabs(target->virtual_x / (float)target->virtual_width); new_x = back_ctrl->width + Q_rint(scroll_ratio * scrollbar->scroll_area); clamp(new_x, back_ctrl->width, (self->width - forward_ctrl->width - slider_ctrl->width)); EZ_control_SetPosition(slider_ctrl, new_x, 0); } }
// Vic: proper float output static void WriteFloatToPortalFile (vec_t f) { int i; i = Q_rint(f); if( f == i ) fprintf( pf, "%i", i ); else fprintf( pf, "%f", f ); }
/** * @brief Returns the number of an existing vertex or allocates a new one * @note Uses hashing */ static int GetVertexnum (const vec3_t in) { vec3_t vert; c_totalverts++; for (int i = 0; i < 3; i++) { if (fabs(in[i] - Q_rint(in[i])) < INTEGRAL_EPSILON) vert[i] = Q_rint(in[i]); else vert[i] = in[i]; } int h = HashVec(vert); for (int vnum = hashverts[h]; vnum; vnum = vertexchain[vnum]) { const float* p = curTile->vertexes[vnum].point; if (fabs(p[0] - vert[0]) < POINT_EPSILON && fabs(p[1] - vert[1]) < POINT_EPSILON && fabs(p[2] - vert[2]) < POINT_EPSILON) return vnum; } /* emit a vertex */ if (curTile->numvertexes == MAX_MAP_VERTS) Sys_Error("numvertexes == MAX_MAP_VERTS"); curTile->vertexes[curTile->numvertexes].point[0] = vert[0]; curTile->vertexes[curTile->numvertexes].point[1] = vert[1]; curTile->vertexes[curTile->numvertexes].point[2] = vert[2]; vertexchain[curTile->numvertexes] = hashverts[h]; hashverts[h] = curTile->numvertexes; c_uniqueverts++; curTile->numvertexes++; curTile->numnormals++; return curTile->numvertexes - 1; }
void SnapWeldVector( vec3_t a, vec3_t b, vec3_t out ){ int i; vec_t ai, bi, outi; /* dummy check */ if ( a == NULL || b == NULL || out == NULL ) { return; } /* do each element */ for ( i = 0; i < 3; i++ ) { /* round to integer */ ai = Q_rint( a[ i ] ); bi = Q_rint( b[ i ] ); /* prefer exact integer */ if ( ai == a[ i ] ) { out[ i ] = a[ i ]; } else if ( bi == b[ i ] ) { out[ i ] = b[ i ]; } /* use nearest */ else if ( fabs( ai - a[ i ] ) < fabs( bi - b[ i ] ) ) { out[ i ] = a[ i ]; } else{ out[ i ] = b[ i ]; } /* snap */ outi = Q_rint( out[ i ] ); if ( fabs( outi - out[ i ] ) <= SNAP_EPSILON ) { out[ i ] = outi; } } }
// // Scrollbar - Calculates the size of the slider button. // static void EZ_scrollbar_CalculateSliderSize(ez_scrollbar_t *scrollbar, ez_control_t *target) { ez_control_t *self = (ez_control_t *)scrollbar; if (target) { if (scrollbar->orientation == vertical) { // Get the percentage of the parent that is shown and calculate the new slider button size from that. float target_height_ratio = (target->height / (float)target->virtual_height); int new_slider_height = max(scrollbar->slider_minsize, Q_rint(target_height_ratio * scrollbar->scroll_area)); EZ_control_SetSize((ez_control_t *)scrollbar->slider, self->width, new_slider_height); } else { float target_width_ratio = (target->width / (float)target->virtual_width); int new_slider_width = max(scrollbar->slider_minsize, Q_rint(target_width_ratio * scrollbar->scroll_area)); EZ_control_SetSize((ez_control_t *)scrollbar->slider, new_slider_width, self->height); } } }
// // Label - The scale of the text changed. // int EZ_label_OnTextScaleChanged(ez_control_t *self, void *ext_event_info) { ez_label_t *label = (ez_label_t *)self; int char_size = (label->ext_flags & label_largefont) ? 64 : 8; label->scaled_char_size = Q_rint(char_size * label->scale); // We need to recalculate the wordwrap stuff since the size changed. EZ_label_CalculateWordwraps(label); CONTROL_EVENT_HANDLER_CALL(NULL, label, ez_label_t, OnTextScaleChanged, NULL); return 0; }
// // Scrollbar - Calculates and sets the parents scroll position based on where the slider button is. // static void EZ_scrollbar_CalculateParentScrollPosition(ez_scrollbar_t *scrollbar, ez_control_t *target) { // ez_control_t *self = (ez_control_t *)scrollbar; ez_control_t *back_ctrl = (ez_control_t *)scrollbar->back; // ez_control_t *forward_ctrl = (ez_control_t *)scrollbar->forward; ez_control_t *slider_ctrl = (ez_control_t *)scrollbar->slider; float scroll_ratio; if (!target) { return; } if (scrollbar->orientation == vertical) { scroll_ratio = (slider_ctrl->y - back_ctrl->height) / (float)scrollbar->scroll_area; EZ_control_SetScrollPosition(target, target->virtual_x, Q_rint(scroll_ratio * target->virtual_height)); } else { scroll_ratio = (slider_ctrl->x - back_ctrl->width) / (float)scrollbar->scroll_area; EZ_control_SetScrollPosition(target, Q_rint(scroll_ratio * target->virtual_width), target->virtual_y); } }
void Movie_TransferStereo16 (void) { if (!Movie_IsActive()) return; // Copy last audio chunk written into our temporary buffer memcpy (capture_audio_samples + (captured_audio_samples << 1), snd_out, snd_linear_count * shm->channels); captured_audio_samples += (snd_linear_count >> 1); if (captured_audio_samples >= Q_rint (host_frametime * shm->speed)) { // We have enough audio samples to match one frame of video Capture_WriteAudio (captured_audio_samples, (byte *)capture_audio_samples); captured_audio_samples = 0; } }
void AdminImpBot () { float coef, i1; if( self->k_adminc < 1 ) { self->k_adminc = 0; return; } i1 = (int)(self->k_adminc -= 1); coef = self->s.v.impulse; while( i1 > 0 ) { coef *= 10; i1--; } self->k_added += coef; if( self->k_adminc < 1 ) { int iPass = cvar( "k_admincode" ); int till = Q_rint(self->k_adm_lasttime + 5 - g_globalvars.time); self->k_adminc = 0; if( self->k_adm_lasttime && till > 0 ) { // probably must help against brute force G_sprint(self, 2, "Wait %d second%s!\n", till, count_s(till) ); return; } if( iPass && self->k_added == iPass ) { BecomeAdmin(self, AF_REAL_ADMIN); return; } else { G_sprint(self, 2, "%s...\n", redtext("Access denied")); self->k_adm_lasttime = g_globalvars.time; } } else G_sprint(self, 2, "%d %s\n", (int)self->k_adminc, redtext("more to go")); }
/* * Cvar_FixCheatVars * * All cheat variables with be reset to default unless cheats are allowed */ void Cvar_FixCheatVars( void ) { struct trie_dump_s *dump; unsigned int i; cvar_flag_t flags = CVAR_CHEAT; if( Cvar_CheatsAllowed() ) return; assert( cvar_trie ); Trie_DumpIf( cvar_trie, "", TRIE_DUMP_VALUES, Cvar_HasFlags, &flags, &dump ); for( i = 0; i < dump->size; ++i ) { cvar_t *const var = (cvar_t *) dump->key_value_vector[i].value; Mem_ZoneFree( var->string ); var->string = ZoneCopyString( var->dvalue ); var->value = atof( var->string ); var->integer = Q_rint( var->value ); } Trie_FreeDump( dump ); }
void SightSound() { if ( streq( self->s.v.classname, "monster_ogre" ) ) sound (self, CHAN_VOICE, "ogre/ogwake.wav", 1, ATTN_NORM); else if ( streq( self->s.v.classname, "monster_knight" ) ) sound (self, CHAN_VOICE, "knight/ksight.wav", 1, ATTN_NORM); else if ( streq( self->s.v.classname, "monster_shambler" ) ) sound (self, CHAN_VOICE, "shambler/ssight.wav", 1, ATTN_NORM); else if ( streq( self->s.v.classname, "monster_demon1" ) ) sound (self, CHAN_VOICE, "demon/sight2.wav", 1, ATTN_NORM); else if ( streq( self->s.v.classname, "monster_wizard" ) ) sound (self, CHAN_VOICE, "wizard/wsight.wav", 1, ATTN_NORM); else if ( streq( self->s.v.classname, "monster_zombie" ) ) sound (self, CHAN_VOICE, "zombie/z_idle.wav", 1, ATTN_NORM); else if ( streq( self->s.v.classname, "monster_dog" ) ) sound (self, CHAN_VOICE, "dog/dsight.wav", 1, ATTN_NORM); else if ( streq( self->s.v.classname, "monster_hell_knight" ) ) sound (self, CHAN_VOICE, "hknight/sight1.wav", 1, ATTN_NORM); else if ( streq( self->s.v.classname, "monster_tarbaby" ) ) sound (self, CHAN_VOICE, "blob/sight1.wav", 1, ATTN_NORM); else if ( streq( self->s.v.classname, "monster_vomit" ) ) sound (self, CHAN_VOICE, "vomitus/v_sight1.wav", 1, ATTN_NORM); else if ( streq( self->s.v.classname, "monster_enforcer" ) ) { float rsnd = Q_rint(g_random() * 3); if (rsnd == 1) sound (self, CHAN_VOICE, "enforcer/sight1.wav", 1, ATTN_NORM); else if (rsnd == 2) sound (self, CHAN_VOICE, "enforcer/sight2.wav", 1, ATTN_NORM); else if (rsnd == 0) sound (self, CHAN_VOICE, "enforcer/sight3.wav", 1, ATTN_NORM); else sound (self, CHAN_VOICE, "enforcer/sight4.wav", 1, ATTN_NORM); } else if ( streq( self->s.v.classname, "monster_army" ) ) sound (self, CHAN_VOICE, "soldier/sight1.wav", 1, ATTN_NORM); else if ( streq( self->s.v.classname, "monster_shalrath" ) ) sound (self, CHAN_VOICE, "shalrath/sight.wav", 1, ATTN_NORM); }
// // Label - Handle a page up/dn key press. // static void EZ_label_PageUpDnKeyDown(ez_label_t *label, int key) { int num_visible_rows = Q_rint((float)label->super.height / label->scaled_char_size); switch (key) { case K_PGUP : { EZ_label_MoveCaretVertically(label, -num_visible_rows); break; } case K_PGDN : { EZ_label_MoveCaretVertically(label, num_visible_rows); break; } default : { break; } } }
/* ============= SV_RunThink Runs thinking code if time. There is some play in the exact time the think function will be called, because it is called before any movement is done in a frame. Not used for pushmove objects, because they must be exact. Returns false if the entity removed itself. ============= */ qboolean SV_RunThink (edict_t *ent) { float thinktime; float oldframe; //johnfitz int i; //johnfitz thinktime = ent->v.nextthink; if (thinktime <= 0 || thinktime > sv.time + host_frametime) return true; if (thinktime < sv.time) thinktime = sv.time; // don't let things stay in the past. // it is possible to start that way // by a trigger with a local time. oldframe = ent->v.frame; //johnfitz ent->v.nextthink = 0; pr_global_struct->time = thinktime; pr_global_struct->self = EDICT_TO_PROG(ent); pr_global_struct->other = EDICT_TO_PROG(sv.edicts); PR_ExecuteProgram (ent->v.think); //johnfitz -- PROTOCOL_FITZQUAKE //capture interval to nextthink here and send it to client for better //lerp timing, but only if interval is not 0.1 (which client assumes) ent->sendinterval = false; if (!ent->free && ent->v.nextthink && (ent->v.movetype == MOVETYPE_STEP || ent->v.frame != oldframe)) { i = Q_rint((ent->v.nextthink-thinktime)*255); if (i >= 0 && i < 256 && i != 25 && i != 26) //25 and 26 are close enough to 0.1 to not send ent->sendinterval = true; } //johnfitz return !ent->free; }
void CreateBrushFaces (void) { int i,j, k; vec_t r; face_t *f; winding_t *w; plane_t plane; mface_t *mf; brush_mins[0] = brush_mins[1] = brush_mins[2] = 99999; brush_maxs[0] = brush_maxs[1] = brush_maxs[2] = -99999; brush_faces = NULL; for (i=0 ; i<numbrushfaces ; i++) { mf = &faces[i]; w = BaseWindingForPlane (&mf->plane); for (j=0 ; j<numbrushfaces && w ; j++) { if (j == i) continue; // flip the plane, because we want to keep the back side VectorSubtract (vec3_origin,faces[j].plane.normal, plane.normal); plane.dist = -faces[j].plane.dist; w = ClipWinding (w, &plane, false); } if (!w) continue; // overcontrained plane // this face is a keeper f = AllocFace (); f->numpoints = w->numpoints; if (f->numpoints > MAXEDGES) Error ("f->numpoints > MAXEDGES"); for (j=0 ; j<w->numpoints ; j++) { for (k=0 ; k<3 ; k++) { r = Q_rint (w->points[j][k]); if ( fabs(w->points[j][k] - r) < ZERO_EPSILON) f->pts[j][k] = r; else f->pts[j][k] = w->points[j][k]; if (f->pts[j][k] < brush_mins[k]) brush_mins[k] = f->pts[j][k]; if (f->pts[j][k] > brush_maxs[k]) brush_maxs[k] = f->pts[j][k]; } } FreeWinding (w); f->texturenum = mf->texinfo; f->planenum = FindPlane (&mf->plane, &f->planeside); f->next = brush_faces; brush_faces = f; CheckFace (f); } }