More conversion

This commit is contained in:
iikorni
2026-08-29 19:17:46 -05:00
parent 0404d430dc
commit 70e5c02355
72 changed files with 13308 additions and 14309 deletions
+7
View File
@@ -0,0 +1,7 @@
<component name="ProjectDictionaryState">
<dictionary name="project">
<words>
<w>convar</w>
</words>
</dictionary>
</component>
+249
View File
@@ -1,6 +1,255 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="BackendCodeEditorSettings"> <component name="BackendCodeEditorSettings">
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CDeclarationWithImplicitIntType/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CommentTypo/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConstevalIfIsAlwaysConstant/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppAbstractClassWithoutSpecifier/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppAbstractFinalClass/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppAbstractVirtualFunctionCallInCtor/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppAccessSpecifierWithNoDeclarations/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppAwaiterTypeIsNotClass/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBooleanIncrementExpression/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBoostFormatBadCode/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBoostFormatLegacyCode/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBoostFormatMixedArgs/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBoostFormatTooFewArgs/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBoostFormatTooManyArgs/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppCStyleCast/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppCVQualifierCanNotBeAppliedToReference/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppClassCanBeFinal/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppClassIsIncomplete/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppClassNeedsConstructorBecauseOfUninitializedMember/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppClassNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppCompileTimeConstantCanBeReplacedWithBooleanConstant/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppConceptNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppConditionalExpressionCanBeSimplified/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppConstParameterInDeclaration/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppConstValueFunctionReturnType/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppConstexprIfDiscardedBranch/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppCoroutineCallResolveError/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAArrayIndexOutOfBounds/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAConstantConditions/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAConstantFunctionResult/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAConstantParameter/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFADeletedPointer/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAEndlessLoop/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAInfiniteRecursion/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAInvalidatedMemory/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFALocalValueEscapesFunction/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFALocalValueEscapesScope/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFALoopConditionNotUpdated/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAMemoryLeak/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFANotInitializedField/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFANullDereference/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFATimeOver/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAUnreachableCode/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAUnreachableFunctionCall/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAUnreadVariable/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAUnusedValue/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclarationHidesLocal/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclarationHidesUncapturedLocal/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclarationSpecifierWithoutDeclarators/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclaratorDisambiguatedAsFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclaratorNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclaratorUsedBeforeInitialization/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDefaultCaseNotHandledInSwitchStatement/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDefaultInitializationWithNoUserConstructor/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDefaultIsUsedAsIdentifier/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDefaultedSpecialMemberFunctionIsImplicitlyDeleted/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDefinitionsOrder/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeletingVoidPointer/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDependentTemplateWithoutTemplateKeyword/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDependentTypeWithoutTypenameKeyword/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeprecatedEntity/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeprecatedOverridenMethod/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeprecatedRegisterStorageClassSpecifier/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDereferenceOperatorLimitExceeded/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDiscardedPostfixOperatorResult/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDoxygenSyntaxError/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDoxygenUndocumentedParameter/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDoxygenUnresolvedReference/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEmptyDeclaration/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceCVQualifiersOrder/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceCVQualifiersPlacement/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceDoStatementBraces/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceForStatementBraces/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceFunctionDeclarationStyle/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceIfStatementBraces/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceNestedNamespacesStyle/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceOverridingDestructorStyle/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceOverridingFunctionStyle/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceTypeAliasCodeStyle/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceWhileStatementBraces/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEntityAssignedButNoRead/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEntityUsedOnlyInUnevaluatedContext/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnumeratorNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEqualOperandsInBinaryExpression/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEvaluationFailure/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppExplicitSpecializationInNonNamespaceScope/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppExpressionWithoutSideEffects/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFinalFunctionInFinalClass/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFinalNonOverridingVirtualFunction/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppForLoopCanBeReplacedWithWhile/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppForwardEnumDeclarationWithoutUnderlyingType/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFunctionDoesntReturnValue/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFunctionIsNotImplemented/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFunctionResultShouldBeUsed/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFunctionalStyleCast/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppHeaderHasBeenAlreadyIncluded/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppHiddenFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppHidingFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppIdenticalOperandsInBinaryExpression/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppIfCanBeReplacedByConstexprIf/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppImplicitDefaultConstructorNotAvailable/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppIncompatiblePointerConversion/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppIncompleteSwitchStatement/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppInconsistentNaming/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppIntegralToPointerConversion/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppInvalidLineContinuation/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppJoinDeclarationAndAssignment/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppLambdaCaptureNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppLocalVariableMayBeConst/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppLocalVariableMightNotBeInitialized/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppLocalVariableWithNonTrivialDtorIsNeverUsed/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppLongFloat/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMemberFunctionMayBeConst/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMemberFunctionMayBeStatic/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMemberInitializersOrder/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMismatchedClassTags/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMissingIncludeGuard/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMissingKeywordThrow/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppModulePartitionWithSeveralPartitionUnits/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtAddressOfClassRValue/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtBindingRValueToLvalueReference/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtCopyElisionInCopyInitDeclarator/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtDoubleUserConversionInCopyInit/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtNotInitializedStaticConstLocalVar/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtReinterpretCastFromNullptr/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMultiCharacterLiteral/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMultiCharacterWideLiteral/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMustBePublicVirtualToImplementInterface/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMutableSpecifierOnReferenceMember/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNoDiscardExpression/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNodiscardFunctionWithoutReturnValue/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonExceptionSafeResourceAcquisition/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonExplicitConversionOperator/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonExplicitConvertingConstructor/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonInlineFunctionDefinitionInHeaderFile/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonInlineVariableDefinitionInHeaderFile/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNotAllPathsReturnValue/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppObjectMemberMightNotBeInitialized/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppOutParameterMustBeWritten/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppOverrideWithDifferentVisibility/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppParameterMayBeConst/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppParameterMayBeConstPtrOrRef/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppParameterNamesMismatch/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppParameterNeverUsed/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPassValueParameterByConstReference/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPointerConversionDropsQualifiers/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPointerToIntegralConversion/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPolymorphicClassWithNonVirtualPublicDestructor/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPossiblyErroneousEmptyStatements/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPossiblyUninitializedMember/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPossiblyUnintendedObjectSlicing/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrecompiledHeaderIsNotIncluded/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrecompiledHeaderNotFound/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrintfBadFormat/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrintfExtraArg/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrintfMissedArg/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrintfRiskyFormat/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrivateSpecialMemberFunctionIsNotImplemented/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRangeBasedForIncompatibleReference/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedefinitionOfDefaultArgumentInOverrideFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantAccessSpecifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantBaseClassAccessSpecifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantBaseClassInitializer/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantBooleanExpressionArgument/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantCastExpression/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantComplexityInComparison/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantConditionalExpression/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantConstSpecifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantControlFlowJump/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantDereferencingAndTakingAddress/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantElaboratedTypeSpecifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantElseKeyword/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantElseKeywordInsideCompoundStatement/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantEmptyDeclaration/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantEmptyStatement/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantExportKeyword/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantFwdClassOrEnumSpecifier/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantInlineSpecifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantLambdaParameterList/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantMemberInitializer/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantNamespaceDefinition/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantParentheses/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantQualifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantQualifierADL/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantStaticSpecifierOnMemberAllocationFunction/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantStaticSpecifierOnThreadLocalLocalVariable/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantTemplateArguments/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantTemplateKeyword/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantTypenameKeyword/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantVoidArgumentList/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantZeroInitializerInAggregateInitialization/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppReferenceToOverriddenVirtualFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppReinterpretCastFromVoidPtr/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRemoveRedundantBraces/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppReplaceMemsetWithZeroInitialization/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppReplaceTieWithStructuredBinding/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppReturnNoValueInNonVoidFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppSmartPointerVsMakeFunction/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppSomeObjectMembersMightNotBeInitialized/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppSpecialFunctionWithoutNoexceptSpecification/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppStaticAssertFailure/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppStaticDataMemberInUnnamedStruct/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppStaticSpecifierOnAnonymousNamespaceMember/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppStringLiteralToCharPointerConversion/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTabsAreDisallowed/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTemplateArgumentsCanBeDeduced/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTemplateParameterNeverUsed/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTemplateParameterShadowing/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppThrowExpressionCanBeReplacedWithRethrow/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTooWideScope/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTooWideScopeInitStatement/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTypeAliasNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUninitializedDependentBaseClass/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUninitializedNonStaticDataMember/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnionMemberOfReferenceType/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnmatchedPragmaEndRegionDirective/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnmatchedPragmaRegionDirective/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnnamedNamespaceInHeaderFile/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnnecessaryWhitespace/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnsignedZeroComparison/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnusedIncludeDirective/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseAlgorithmWithCount/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseAssociativeContains/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseAuto/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseAutoForNumeric/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseDesignatedInitializers/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseElementsView/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseEraseAlgorithm/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseFamiliarTemplateSyntaxForGenericLambdas/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseInternalLinkage/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseRangeAlgorithm/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseStdSize/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseStructuredBinding/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseTypeTraitAlias/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUserDefinedLiteralSuffixDoesNotStartWithUnderscore/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUsingResultOfAssignmentAsCondition/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppVariableCanBeMadeConstexpr/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppVirtualFunctionCallInsideCtor/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppVirtualFunctionInFinalClass/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppVolatileParameterInDeclaration/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppWarningDirective/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppWrongIncludesOrder/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppWrongSlashesInIncludeDirective/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppZeroConstantCanBeReplacedWithNullptr/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppZeroValuedExpressionUsedAsNullPointer/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=IdentifierTypo/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=IfStdIsConstantEvaluatedCanBeReplaced/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=StdIsConstantEvaluatedWillAlwaysEvaluateToConstant/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=StringLiteralTypo/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppClangFormat/EnableClangFormatSupport/@EntryValue" value="false" type="bool" /> <option name="/Default/CodeStyle/CodeFormatting/CppClangFormat/EnableClangFormatSupport/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_ARGUMENT/@EntryValue" value="true" type="bool" /> <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_ARGUMENT/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_BINARY_EXPRESSIONS_CHAIN/@EntryValue" value="true" type="bool" /> <option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_BINARY_EXPRESSIONS_CHAIN/@EntryValue" value="true" type="bool" />
Generated
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings"> <component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" /> <mapping directory="" vcs="Git" />
</component> </component>
</project> </project>
+100 -23
View File
@@ -3,9 +3,13 @@
<component name="AutoImportSettings"> <component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="CMakePresetLoader"><![CDATA[{ <component name="BackendCodeEditorMiscSettings">
"useNewFormat": true <option name="/Default/Housekeeping/FeatureSuggestion/FeatureSuggestionManager/DisabledSuggesters/=SwitchToGoToActionSuggester/@EntryIndexedValue" value="true" type="bool" />
}]]></component> <option name="/Default/Housekeeping/LiveTemplatesHousekeeping/HotspotSessionHintIsShown/@EntryValue" value="true" type="bool" />
</component>
<component name="CMakePresetLoader">{
&quot;useNewFormat&quot;: true
}</component>
<component name="CMakeProjectFlavorService"> <component name="CMakeProjectFlavorService">
<option name="flavorId" value="CMakePlainProjectFlavor" /> <option name="flavorId" value="CMakePlainProjectFlavor" />
</component> </component>
@@ -23,8 +27,77 @@
</configurations> </configurations>
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="f5455ea3-1ba8-4b1e-84ce-0eab50a09cdc" name="Changes" comment=""> <list default="true" id="f5455ea3-1ba8-4b1e-84ce-0eab50a09cdc" name="Changes" comment="Begin converting QS engine to CPP">
<change afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" /> <change afterPath="$PROJECT_DIR$/.idea/dictionaries/project.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/Quake/convar.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/editor.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/editor.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/vcs.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/CMakeLists.txt" beforeDir="false" afterPath="$PROJECT_DIR$/CMakeLists.txt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Misc/fix_externaltex.patch" beforeDir="false" afterPath="$PROJECT_DIR$/Misc/fix_externaltex.patch" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/bgmusic.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/bgmusic.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/bgmusic.hpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/bgmusic.hpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/cd_sdl.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/cd_sdl.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/cfgfile.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/cfgfile.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/chase.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/chase.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/cl_demo.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/cl_demo.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/cl_input.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/cl_input.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/cl_main.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/cl_main.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/cl_parse.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/cl_parse.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/client.hpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/client.hpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/cmd.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/cmd.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/cmd.hpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/cmd.hpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/common.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/common.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/common.hpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/common.hpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/console.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/console.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/cvar.cpp" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/cvar.hpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/convar.hpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/gl_draw.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/gl_draw.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/gl_fog.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/gl_fog.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/gl_model.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/gl_model.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/gl_refrag.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/gl_refrag.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/gl_rlight.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/gl_rlight.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/gl_rmain.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/gl_rmain.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/gl_rmisc.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/gl_rmisc.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/gl_screen.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/gl_screen.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/gl_sky.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/gl_sky.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/gl_texmgr.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/gl_texmgr.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/gl_vidsdl.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/gl_vidsdl.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/gl_warp.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/gl_warp.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/glquake.hpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/glquake.hpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/host.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/host.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/host_cmd.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/host_cmd.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/in_sdl.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/in_sdl.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/keys.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/keys.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/menu.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/menu.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/net.hpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/net.hpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/net_dgrm.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/net_dgrm.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/net_main.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/net_main.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/pl_linux.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/pl_linux.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/pl_osx.m" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/pl_osx.m" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/pl_win.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/pl_win.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/pr_cmds.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/pr_cmds.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/pr_edict.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/pr_edict.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/progs.hpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/progs.hpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/q_sound.hpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/q_sound.hpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/q_stdinc.hpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/q_stdinc.hpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/quakedef.hpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/quakedef.hpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/r_alias.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/r_alias.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/r_brush.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/r_brush.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/r_part.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/r_part.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/r_world.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/r_world.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/sbar.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/sbar.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/screen.hpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/screen.hpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/server.hpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/server.hpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/snd_dma.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/snd_dma.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/snd_mp3.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/snd_mp3.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/sv_main.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/sv_main.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/sv_phys.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/sv_phys.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/sv_user.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/sv_user.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/sys_sdl_unix.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/sys_sdl_unix.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/view.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/view.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/view.hpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/view.hpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Quake/zone.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Quake/zone.cpp" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -38,6 +111,9 @@
<component name="Git.Settings"> <component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component> </component>
<component name="HighlightingSettingsPerFile">
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
</component>
<component name="MacroExpansionManager"> <component name="MacroExpansionManager">
<option name="directoryName" value="5yRIaLtN" /> <option name="directoryName" value="5yRIaLtN" />
</component> </component>
@@ -47,10 +123,10 @@
<option name="minorVersion" value="2.1" /> <option name="minorVersion" value="2.1" />
<option name="productBranch" value="Classic" /> <option name="productBranch" value="Classic" />
</component> </component>
<component name="ProjectColorInfo"><![CDATA[{ <component name="ProjectColorInfo">{
"associatedIndex": 6, &quot;associatedIndex&quot;: 6,
"fromUser": false &quot;fromUser&quot;: false
}]]></component> }</component>
<component name="ProjectId" id="3IFldDeo8ZZSrZixdcT6JdBiaj1" /> <component name="ProjectId" id="3IFldDeo8ZZSrZixdcT6JdBiaj1" />
<component name="ProjectViewState"> <component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
@@ -64,13 +140,15 @@
"RunOnceActivity.RadMigrateCodeStyle": "true", "RunOnceActivity.RadMigrateCodeStyle": "true",
"RunOnceActivity.ShowReadmeOnStart": "true", "RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.cidr.known.project.marker": "true", "RunOnceActivity.cidr.known.project.marker": "true",
"RunOnceActivity.git.unshallow": "true",
"RunOnceActivity.readMode.enableVisualFormatting": "true", "RunOnceActivity.readMode.enableVisualFormatting": "true",
"RunOnceActivity.typescript.service.memoryLimit.init": "true", "RunOnceActivity.typescript.service.memoryLimit.init": "true",
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
"cf.first.check.clang-format": "false", "cf.first.check.clang-format": "false",
"cidr.known.project.marker": "true", "cidr.known.project.marker": "true",
"codeWithMe.voiceChat.enabledByDefault": "false", "codeWithMe.voiceChat.enabledByDefault": "false",
"git-widget-placeholder": "master", "git-widget-placeholder": "master",
"last_opened_file_path": "/home/iikorni/Downloads/quakespasm-0.96.3", "last_opened_file_path": "/home/iikorni/Downloads/DOOM-master/linuxdoom-1.10",
"node.js.detected.package.eslint": "true", "node.js.detected.package.eslint": "true",
"node.js.detected.package.jshint": "true", "node.js.detected.package.jshint": "true",
"node.js.detected.package.tslint": "true", "node.js.detected.package.tslint": "true",
@@ -86,29 +164,24 @@
</key> </key>
</component> </component>
<component name="RunManager"> <component name="RunManager">
<configuration default="true" type="CMakeRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true">
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
</configuration>
<configuration name="quakespasm" type="CMakeRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="quakespasm" TARGET_NAME="quakespasm" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="quakespasm" RUN_TARGET_NAME="quakespasm"> <configuration name="quakespasm" type="CMakeRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="quakespasm" TARGET_NAME="quakespasm" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="quakespasm" RUN_TARGET_NAME="quakespasm">
<method v="2"> <method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" /> <option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method> </method>
</configuration> </configuration>
</component> </component>
<component name="SelectedDebugProfileService"><![CDATA[{ <component name="SelectedDebugProfileService">{
"profileIdByStamp": [ &quot;profileIdByStamp&quot;: [
{ {
"first": { &quot;first&quot;: {
"##RUN_CONFIGURATION##": "CMake Application.quakespasm", &quot;##RUN_CONFIGURATION##&quot;: &quot;CMake Application.quakespasm&quot;,
"cmake": "CMakeBuildProfile:Debug" &quot;cmake&quot;: &quot;CMakeBuildProfile:Debug&quot;
}, },
"second": "27852a6b-aee6-4e6c-a703-78c08d632bb7" &quot;second&quot;: &quot;27852a6b-aee6-4e6c-a703-78c08d632bb7&quot;
} }
], ],
"modificationCount": 4 &quot;modificationCount&quot;: 4
}]]></component> }</component>
<component name="TaskManager"> <component name="TaskManager">
<task active="true" id="Default" summary="Default task"> <task active="true" id="Default" summary="Default task">
<changelist id="f5455ea3-1ba8-4b1e-84ce-0eab50a09cdc" name="Changes" comment="" /> <changelist id="f5455ea3-1ba8-4b1e-84ce-0eab50a09cdc" name="Changes" comment="" />
@@ -139,4 +212,8 @@
</map> </map>
</option> </option>
</component> </component>
<component name="VcsManagerConfiguration">
<MESSAGE value="Begin converting QS engine to CPP" />
<option name="LAST_COMMIT_MESSAGE" value="Begin converting QS engine to CPP" />
</component>
</project> </project>
+1 -1
View File
@@ -7,7 +7,7 @@ find_package(SDL)
find_package(SDL_net) find_package(SDL_net)
find_package(OpenGL) find_package(OpenGL)
add_executable(quakespasm Quake/bgmusic.cpp Quake/cd_sdl.cpp Quake/cfgfile.cpp Quake/chase.cpp Quake/cl_demo.cpp Quake/cl_input.cpp Quake/cl_main.cpp Quake/cl_parse.cpp Quake/cl_tent.cpp Quake/cmd.cpp Quake/common.cpp Quake/console.cpp Quake/crc.cpp Quake/cvar.cpp Quake/gl_draw.cpp Quake/gl_fog.cpp Quake/gl_mesh.cpp Quake/gl_model.cpp Quake/gl_refrag.cpp Quake/gl_rlight.cpp Quake/gl_rmain.cpp Quake/gl_rmisc.cpp Quake/gl_screen.cpp Quake/gl_sky.cpp Quake/gl_texmgr.cpp Quake/gl_vidsdl.cpp Quake/gl_warp.cpp Quake/host.cpp Quake/host_cmd.cpp Quake/image.cpp Quake/in_sdl.cpp Quake/keys.cpp Quake/main_sdl.cpp Quake/mathlib.cpp Quake/menu.cpp Quake/miniz.cpp Quake/net_bsd.cpp Quake/net_dgrm.cpp Quake/net_loop.cpp Quake/net_main.cpp Quake/net_udp.cpp Quake/pl_linux.cpp Quake/pr_cmds.cpp Quake/pr_edict.cpp Quake/pr_exec.cpp Quake/r_alias.cpp Quake/r_brush.cpp Quake/r_part.cpp Quake/r_sprite.cpp Quake/r_world.cpp Quake/sbar.cpp Quake/snd_codec.cpp Quake/snd_dma.cpp Quake/snd_flac.cpp Quake/snd_mem.cpp Quake/snd_mikmod.cpp Quake/snd_mix.cpp Quake/snd_modplug.cpp Quake/snd_mp3.cpp Quake/snd_mp3tag.cpp Quake/snd_mpg123.cpp Quake/snd_opus.cpp Quake/snd_sdl.cpp Quake/snd_umx.cpp Quake/snd_vorbis.cpp Quake/snd_wave.cpp Quake/snd_xmp.cpp Quake/strlcat.cpp Quake/strlcpy.cpp Quake/sv_main.cpp Quake/sv_move.cpp Quake/sv_phys.cpp Quake/sv_user.cpp Quake/sys_sdl_unix.cpp Quake/view.cpp Quake/wad.cpp Quake/world.cpp Quake/zone.cpp ) add_executable(quakespasm Quake/bgmusic.cpp Quake/cd_sdl.cpp Quake/cfgfile.cpp Quake/chase.cpp Quake/cl_demo.cpp Quake/cl_input.cpp Quake/cl_main.cpp Quake/cl_parse.cpp Quake/cl_tent.cpp Quake/cmd.cpp Quake/common.cpp Quake/console.cpp Quake/crc.cpp Quake/convar.cpp Quake/gl_draw.cpp Quake/gl_fog.cpp Quake/gl_mesh.cpp Quake/gl_model.cpp Quake/gl_refrag.cpp Quake/gl_rlight.cpp Quake/gl_rmain.cpp Quake/gl_rmisc.cpp Quake/gl_screen.cpp Quake/gl_sky.cpp Quake/gl_texmgr.cpp Quake/gl_vidsdl.cpp Quake/gl_warp.cpp Quake/host.cpp Quake/host_cmd.cpp Quake/image.cpp Quake/in_sdl.cpp Quake/keys.cpp Quake/main_sdl.cpp Quake/mathlib.cpp Quake/menu.cpp Quake/miniz.cpp Quake/net_bsd.cpp Quake/net_dgrm.cpp Quake/net_loop.cpp Quake/net_main.cpp Quake/net_udp.cpp Quake/pl_linux.cpp Quake/pr_cmds.cpp Quake/pr_edict.cpp Quake/pr_exec.cpp Quake/r_alias.cpp Quake/r_brush.cpp Quake/r_part.cpp Quake/r_sprite.cpp Quake/r_world.cpp Quake/sbar.cpp Quake/snd_codec.cpp Quake/snd_dma.cpp Quake/snd_flac.cpp Quake/snd_mem.cpp Quake/snd_mikmod.cpp Quake/snd_mix.cpp Quake/snd_modplug.cpp Quake/snd_mp3.cpp Quake/snd_mp3tag.cpp Quake/snd_mpg123.cpp Quake/snd_opus.cpp Quake/snd_sdl.cpp Quake/snd_umx.cpp Quake/snd_vorbis.cpp Quake/snd_wave.cpp Quake/snd_xmp.cpp Quake/strlcat.cpp Quake/strlcpy.cpp Quake/sv_main.cpp Quake/sv_move.cpp Quake/sv_phys.cpp Quake/sv_user.cpp Quake/sys_sdl_unix.cpp Quake/view.cpp Quake/wad.cpp Quake/world.cpp Quake/zone.cpp )
target_link_libraries(quakespasm OpenGL::GL) target_link_libraries(quakespasm OpenGL::GL)
target_link_libraries(quakespasm SDL::SDL) target_link_libraries(quakespasm SDL::SDL)
+4 -4
View File
@@ -104,10 +104,10 @@ index 963d55e..e9b251b 100644
extern gltexture_t *playertextures[MAX_SCOREBOARD]; //johnfitz extern gltexture_t *playertextures[MAX_SCOREBOARD]; //johnfitz
@@ -230,6 +231,7 @@ void R_Init (void) @@ -230,6 +231,7 @@ void R_Init (void)
Cvar_SetCallback (&r_lavaalpha, R_SetLavaalpha_f); r_lavaalpha.set_callback(R_SetLavaalpha_f);
Cvar_SetCallback (&r_telealpha, R_SetTelealpha_f); r_telealpha.set_callback(R_SetTelealpha_f);
Cvar_SetCallback (&r_slimealpha, R_SetSlimealpha_f); r_slimealpha.set_callback(R_SetSlimealpha_f);
+ Cvar_RegisterVariable (&r_externaltexture_fix);//mk + r_externaltexture_fix.inscribe();//mk
R_InitParticles (); R_InitParticles ();
R_SetClearColor_f (&r_clearcolor); //johnfitz R_SetClearColor_f (&r_clearcolor); //johnfitz
+20 -20
View File
@@ -29,7 +29,7 @@
#define MUSIC_DIRNAME "music" #define MUSIC_DIRNAME "music"
qboolean bgmloop; qboolean bgmloop;
cvar_t bgm_extmusic = {"bgm_extmusic", "1", CVAR_ARCHIVE}; convar bgm_extmusic{"bgm_extmusic", "1", {.archive = true}};
static qboolean no_extmusic= false; static qboolean no_extmusic= false;
static float old_volume = -1.0f; static float old_volume = -1.0f;
@@ -76,8 +76,8 @@ static snd_stream_t *bgmstream = NULL;
static void BGM_Play_f (void) static void BGM_Play_f (void)
{ {
if (Cmd_Argc() == 2) { if (command::argc() == 2) {
BGM_Play (Cmd_Argv(1)); BGM_Play (command::argv(1)->c_str());
} }
else { else {
Con_Printf ("music <musicfile>\n"); Con_Printf ("music <musicfile>\n");
@@ -96,14 +96,14 @@ static void BGM_Resume_f (void)
static void BGM_Loop_f (void) static void BGM_Loop_f (void)
{ {
if (Cmd_Argc() == 2) { if (command::argc() == 2) {
if (q_strcasecmp(Cmd_Argv(1), "0") == 0 || if (q_strcasecmp(command::argv(1)->c_str(), "0") == 0 ||
q_strcasecmp(Cmd_Argv(1),"off") == 0) q_strcasecmp(command::argv(1)->c_str(),"off") == 0)
bgmloop = false; bgmloop = false;
else if (q_strcasecmp(Cmd_Argv(1), "1") == 0 || else if (q_strcasecmp(command::argv(1)->c_str(), "1") == 0 ||
q_strcasecmp(Cmd_Argv(1),"on") == 0) q_strcasecmp(command::argv(1)->c_str(),"on") == 0)
bgmloop = true; bgmloop = true;
else if (q_strcasecmp(Cmd_Argv(1),"toggle") == 0) else if (q_strcasecmp(command::argv(1)->c_str(),"toggle") == 0)
bgmloop = !bgmloop; bgmloop = !bgmloop;
if (bgmstream) bgmstream->loop = bgmloop; if (bgmstream) bgmstream->loop = bgmloop;
@@ -122,11 +122,11 @@ static void BGM_Stop_f (void)
static void BGM_Jump_f (void) static void BGM_Jump_f (void)
{ {
if (Cmd_Argc() != 2) { if (command::argc() != 2) {
Con_Printf ("music_jump <ordernum>\n"); Con_Printf ("music_jump <ordernum>\n");
} }
else if (bgmstream) { else if (bgmstream) {
S_CodecJumpToOrder(bgmstream, atoi(Cmd_Argv(1))); S_CodecJumpToOrder(bgmstream, atoi(command::argv(1)->c_str()));
} }
} }
@@ -135,13 +135,13 @@ qboolean BGM_Init (void)
music_handler_t *handlers = NULL; music_handler_t *handlers = NULL;
int i; int i;
Cvar_RegisterVariable(&bgm_extmusic); bgm_extmusic.inscribe();
Cmd_AddCommand("music", BGM_Play_f); command::add("music", BGM_Play_f);
Cmd_AddCommand("music_pause", BGM_Pause_f); command::add("music_pause", BGM_Pause_f);
Cmd_AddCommand("music_resume", BGM_Resume_f); command::add("music_resume", BGM_Resume_f);
Cmd_AddCommand("music_loop", BGM_Loop_f); command::add("music_loop", BGM_Loop_f);
Cmd_AddCommand("music_stop", BGM_Stop_f); command::add("music_stop", BGM_Stop_f);
Cmd_AddCommand("music_jump", BGM_Jump_f); command::add("music_jump", BGM_Jump_f);
if (COM_CheckParm("-noextmusic") != 0) if (COM_CheckParm("-noextmusic") != 0)
no_extmusic = true; no_extmusic = true;
@@ -467,9 +467,9 @@ void BGM_Update (void)
if (old_volume != bgmvolume.value) if (old_volume != bgmvolume.value)
{ {
if (bgmvolume.value < 0) if (bgmvolume.value < 0)
Cvar_SetQuick (&bgmvolume, "0"); bgmvolume.set("0");
else if (bgmvolume.value > 1) else if (bgmvolume.value > 1)
Cvar_SetQuick (&bgmvolume, "1"); bgmvolume.set("1");
old_volume = bgmvolume.value; old_volume = bgmvolume.value;
} }
if (bgmstream) if (bgmstream)
+1 -1
View File
@@ -26,7 +26,7 @@
#define _BGMUSIC_H_ #define _BGMUSIC_H_
extern qboolean bgmloop; extern qboolean bgmloop;
extern cvar_t bgm_extmusic; extern convar bgm_extmusic;
qboolean BGM_Init (void); qboolean BGM_Init (void);
void BGM_Shutdown (void); void BGM_Shutdown (void);
+7 -7
View File
@@ -221,7 +221,7 @@ static void CD_f (void)
const char *command; const char *command;
int ret, n; int ret, n;
if (Cmd_Argc() < 2) if (command::argc() < 2)
{ {
Con_Printf("commands:"); Con_Printf("commands:");
Con_Printf("on, off, reset, remap, \n"); Con_Printf("on, off, reset, remap, \n");
@@ -230,7 +230,7 @@ static void CD_f (void)
return; return;
} }
command = Cmd_Argv (1); command = command::argv (1)->c_str();
if (q_strcasecmp(command, "on") == 0) if (q_strcasecmp(command, "on") == 0)
{ {
@@ -259,7 +259,7 @@ static void CD_f (void)
if (q_strcasecmp(command, "remap") == 0) if (q_strcasecmp(command, "remap") == 0)
{ {
ret = Cmd_Argc() - 2; ret = command::argc() - 2;
if (ret <= 0) if (ret <= 0)
{ {
for (n = 1; n < 100; n++) for (n = 1; n < 100; n++)
@@ -268,7 +268,7 @@ static void CD_f (void)
return; return;
} }
for (n = 1; n <= ret; n++) for (n = 1; n <= ret; n++)
remap[n] = atoi(Cmd_Argv (n + 1)); remap[n] = atoi(command::argv (n + 1)->c_str());
return; return;
} }
@@ -284,7 +284,7 @@ static void CD_f (void)
if (q_strcasecmp(command, "play") == 0) if (q_strcasecmp(command, "play") == 0)
{ {
n = atoi(Cmd_Argv (2)); n = atoi(command::argv (2)->c_str());
if (n == 0) if (n == 0)
n = 1; n = 1;
CDAudio_Play((byte)n, false); CDAudio_Play((byte)n, false);
@@ -293,7 +293,7 @@ static void CD_f (void)
if (q_strcasecmp(command, "loop") == 0) if (q_strcasecmp(command, "loop") == 0)
{ {
CDAudio_Play((byte)atoi(Cmd_Argv (2)), true); CDAudio_Play((byte)atoi(command::argv (2)->c_str()), true);
return; return;
} }
@@ -564,7 +564,7 @@ int CDAudio_Init(void)
cdValid = false; cdValid = false;
} }
Cmd_AddCommand ("cd", CD_f); command::add ("cd", CD_f);
hw_vol_works = CD_GetVolume (NULL); /* no SDL support at present. */ hw_vol_works = CD_GetVolume (NULL); /* no SDL support at present. */
if (hw_vol_works) if (hw_vol_works)
+2 -2
View File
@@ -94,7 +94,7 @@ void CFG_ReadCvars (const char **vars, int num_vars)
tmp = strchr(buff, '\"'); tmp = strchr(buff, '\"');
if (tmp) if (tmp)
{ {
Cvar_Set (vars[i], tmp + 1); convar::set(vars[i], tmp + 1);
j++; j++;
break; break;
} }
@@ -135,7 +135,7 @@ void CFG_ReadCvarOverrides (const char **vars, int num_vars)
if (j != 0 && j < com_argc - 1) if (j != 0 && j < com_argc - 1)
{ {
if (com_argv[j + 1][0] != '-' && com_argv[j + 1][0] != '+') if (com_argv[j + 1][0] != '-' && com_argv[j + 1][0] != '+')
Cvar_Set(vars[i], com_argv[j + 1]); convar::set(vars[i], com_argv[j + 1]);
} }
} }
} }
+8 -8
View File
@@ -23,10 +23,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "quakedef.hpp" #include "quakedef.hpp"
cvar_t chase_back = {"chase_back", "100", CVAR_NONE}; convar chase_back{"chase_back", "100"};
cvar_t chase_up = {"chase_up", "16", CVAR_NONE}; convar chase_up{"chase_up", "16"};
cvar_t chase_right = {"chase_right", "0", CVAR_NONE}; convar chase_right{"chase_right", "0"};
cvar_t chase_active = {"chase_active", "0", CVAR_NONE}; convar chase_active{"chase_active", "0"};
/* /*
============== ==============
@@ -35,10 +35,10 @@ Chase_Init
*/ */
void Chase_Init (void) void Chase_Init (void)
{ {
Cvar_RegisterVariable (&chase_back); chase_back.inscribe();
Cvar_RegisterVariable (&chase_up); chase_up.inscribe();
Cvar_RegisterVariable (&chase_right); chase_right.inscribe();
Cvar_RegisterVariable (&chase_active); chase_active.inscribe();
} }
/* /*
+13 -12
View File
@@ -20,6 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include <cstring> #include <cstring>
#include <format>
#include "quakedef.hpp" #include "quakedef.hpp"
@@ -202,7 +203,7 @@ stop recording a demo
*/ */
void CL_Stop_f (void) void CL_Stop_f (void)
{ {
if (cmd_source != src_command) if (command::last_source != command::source::command)
return; return;
if (!cls.demorecording) if (!cls.demorecording)
@@ -239,7 +240,7 @@ void CL_Record_f (void)
char name[MAX_OSPATH]; char name[MAX_OSPATH];
int track; int track;
if (cmd_source != src_command) if (command::last_source != command::source::command)
return; return;
if (cls.demoplayback) if (cls.demoplayback)
@@ -251,14 +252,14 @@ void CL_Record_f (void)
if (cls.demorecording) if (cls.demorecording)
CL_Stop_f(); CL_Stop_f();
c = Cmd_Argc(); c = command::argc();
if (c != 2 && c != 3 && c != 4) if (c != 2 && c != 3 && c != 4)
{ {
Con_Printf ("record <demoname> [<map> [cd track]]\n"); Con_Printf ("record <demoname> [<map> [cd track]]\n");
return; return;
} }
if (strstr(Cmd_Argv(1), "..")) if (strstr(command::argv(1).value_or("").c_str(), ".."))
{ {
Con_Printf ("Relative pathnames are not allowed.\n"); Con_Printf ("Relative pathnames are not allowed.\n");
return; return;
@@ -280,7 +281,7 @@ void CL_Record_f (void)
// write the forced cd track number, or -1 // write the forced cd track number, or -1
if (c == 4) if (c == 4)
{ {
track = atoi(Cmd_Argv(3)); track = atoi(command::argv(3)->c_str());
Con_Printf ("Forcing CD track to %i\n", cls.forcetrack); Con_Printf ("Forcing CD track to %i\n", cls.forcetrack);
} }
else else
@@ -288,12 +289,12 @@ void CL_Record_f (void)
track = -1; track = -1;
} }
q_snprintf (name, sizeof(name), "%s/%s", com_gamedir, Cmd_Argv(1)); q_snprintf (name, sizeof(name), "%s/%s", com_gamedir, command::argv(1).value_or("").c_str());
// start the map up // start the map up
if (c > 2) if (c > 2)
{ {
Cmd_ExecuteString ( va("map %s", Cmd_Argv(2)), src_command); command::execute_string ( std::format("map {:s}", *command::argv(2)), command::source::command);
if (cls.state != ca_connected) if (cls.state != ca_connected)
return; return;
} }
@@ -403,10 +404,10 @@ void CL_PlayDemo_f (void)
{ {
char name[MAX_OSPATH]; char name[MAX_OSPATH];
if (cmd_source != src_command) if (command::last_source != command::source::command)
return; return;
if (Cmd_Argc() != 2) if (command::argc() != 2)
{ {
Con_Printf ("playdemo <demoname> : plays a demo\n"); Con_Printf ("playdemo <demoname> : plays a demo\n");
return; return;
@@ -416,7 +417,7 @@ void CL_PlayDemo_f (void)
CL_Disconnect (); CL_Disconnect ();
// open the demo file // open the demo file
std::strncpy(name, Cmd_Argv(1), sizeof(name)); std::strncpy(name, command::argv(1).value_or("").c_str(), sizeof(name));
COM_AddExtension (name, ".dem", sizeof(name)); COM_AddExtension (name, ".dem", sizeof(name));
Con_Printf ("Playing demo from %s.\n", name); Con_Printf ("Playing demo from %s.\n", name);
@@ -480,10 +481,10 @@ timedemo [demoname]
*/ */
void CL_TimeDemo_f (void) void CL_TimeDemo_f (void)
{ {
if (cmd_source != src_command) if (command::last_source != command::source::command)
return; return;
if (Cmd_Argc() != 2) if (command::argc() != 2)
{ {
Con_Printf ("timedemo <demoname> : gets demo speeds\n"); Con_Printf ("timedemo <demoname> : gets demo speeds\n");
return; return;
+51 -52
View File
@@ -26,8 +26,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "quakedef.hpp" #include "quakedef.hpp"
extern cvar_t cl_maxpitch; //johnfitz -- variable pitch clamping extern convar cl_maxpitch; //johnfitz -- variable pitch clamping
extern cvar_t cl_minpitch; //johnfitz -- variable pitch clamping extern convar cl_minpitch; //johnfitz -- variable pitch clamping
/* /*
=============================================================================== ===============================================================================
@@ -63,11 +63,10 @@ int in_impulse;
void KeyDown (kbutton_t *b) void KeyDown (kbutton_t *b)
{ {
int k; int k;
const char *c;
c = Cmd_Argv(1); auto c = command::argv(1).value_or("");
if (c[0]) if (!c.empty())
k = atoi(c); k = atoi(c.c_str());
else else
k = -1; // typed manually at the console for continuous down k = -1; // typed manually at the console for continuous down
@@ -94,7 +93,7 @@ void KeyUp (kbutton_t *b)
int k; int k;
const char *c; const char *c;
c = Cmd_Argv(1); c = command::argv(1)->c_str();
if (c[0]) if (c[0])
k = atoi(c); k = atoi(c);
else else
@@ -161,7 +160,7 @@ void IN_UseUp (void) {KeyUp(&in_use);}
void IN_JumpDown (void) {KeyDown(&in_jump);} void IN_JumpDown (void) {KeyDown(&in_jump);}
void IN_JumpUp (void) {KeyUp(&in_jump);} void IN_JumpUp (void) {KeyUp(&in_jump);}
void IN_Impulse (void) {in_impulse=Q_atoi(Cmd_Argv(1));} void IN_Impulse (void) {in_impulse=Q_atoi(command::argv(1)->c_str());}
/* /*
=============== ===============
@@ -220,19 +219,19 @@ float CL_KeyState (kbutton_t *key)
//========================================================================== //==========================================================================
cvar_t cl_upspeed = {"cl_upspeed","200",CVAR_NONE}; convar cl_upspeed{"cl_upspeed","200"};
cvar_t cl_forwardspeed = {"cl_forwardspeed","200", CVAR_ARCHIVE}; convar cl_forwardspeed{"cl_forwardspeed","200", {.archive = true}};
cvar_t cl_backspeed = {"cl_backspeed","200", CVAR_ARCHIVE}; convar cl_backspeed{"cl_backspeed","200", {.archive = true}};
cvar_t cl_sidespeed = {"cl_sidespeed","350",CVAR_NONE}; convar cl_sidespeed{"cl_sidespeed","350"};
cvar_t cl_movespeedkey = {"cl_movespeedkey","2.0",CVAR_NONE}; convar cl_movespeedkey{"cl_movespeedkey","2.0"};
cvar_t cl_yawspeed = {"cl_yawspeed","140",CVAR_NONE}; convar cl_yawspeed{"cl_yawspeed","140"};
cvar_t cl_pitchspeed = {"cl_pitchspeed","150",CVAR_NONE}; convar cl_pitchspeed{"cl_pitchspeed","150"};
cvar_t cl_anglespeedkey = {"cl_anglespeedkey","1.5",CVAR_NONE}; convar cl_anglespeedkey{"cl_anglespeedkey","1.5"};
cvar_t cl_alwaysrun = {"cl_alwaysrun","0",CVAR_ARCHIVE}; // QuakeSpasm -- new always run convar cl_alwaysrun{"cl_alwaysrun","0",{.archive = true}}; // QuakeSpasm -- new always run
/* /*
================ ================
@@ -414,41 +413,41 @@ CL_InitInput
*/ */
void CL_InitInput (void) void CL_InitInput (void)
{ {
Cmd_AddCommand ("+moveup",IN_UpDown); command::add ("+moveup",IN_UpDown);
Cmd_AddCommand ("-moveup",IN_UpUp); command::add ("-moveup",IN_UpUp);
Cmd_AddCommand ("+movedown",IN_DownDown); command::add ("+movedown",IN_DownDown);
Cmd_AddCommand ("-movedown",IN_DownUp); command::add ("-movedown",IN_DownUp);
Cmd_AddCommand ("+left",IN_LeftDown); command::add ("+left",IN_LeftDown);
Cmd_AddCommand ("-left",IN_LeftUp); command::add ("-left",IN_LeftUp);
Cmd_AddCommand ("+right",IN_RightDown); command::add ("+right",IN_RightDown);
Cmd_AddCommand ("-right",IN_RightUp); command::add ("-right",IN_RightUp);
Cmd_AddCommand ("+forward",IN_ForwardDown); command::add ("+forward",IN_ForwardDown);
Cmd_AddCommand ("-forward",IN_ForwardUp); command::add ("-forward",IN_ForwardUp);
Cmd_AddCommand ("+back",IN_BackDown); command::add ("+back",IN_BackDown);
Cmd_AddCommand ("-back",IN_BackUp); command::add ("-back",IN_BackUp);
Cmd_AddCommand ("+lookup", IN_LookupDown); command::add ("+lookup", IN_LookupDown);
Cmd_AddCommand ("-lookup", IN_LookupUp); command::add ("-lookup", IN_LookupUp);
Cmd_AddCommand ("+lookdown", IN_LookdownDown); command::add ("+lookdown", IN_LookdownDown);
Cmd_AddCommand ("-lookdown", IN_LookdownUp); command::add ("-lookdown", IN_LookdownUp);
Cmd_AddCommand ("+strafe", IN_StrafeDown); command::add ("+strafe", IN_StrafeDown);
Cmd_AddCommand ("-strafe", IN_StrafeUp); command::add ("-strafe", IN_StrafeUp);
Cmd_AddCommand ("+moveleft", IN_MoveleftDown); command::add ("+moveleft", IN_MoveleftDown);
Cmd_AddCommand ("-moveleft", IN_MoveleftUp); command::add ("-moveleft", IN_MoveleftUp);
Cmd_AddCommand ("+moveright", IN_MoverightDown); command::add ("+moveright", IN_MoverightDown);
Cmd_AddCommand ("-moveright", IN_MoverightUp); command::add ("-moveright", IN_MoverightUp);
Cmd_AddCommand ("+speed", IN_SpeedDown); command::add ("+speed", IN_SpeedDown);
Cmd_AddCommand ("-speed", IN_SpeedUp); command::add ("-speed", IN_SpeedUp);
Cmd_AddCommand ("+attack", IN_AttackDown); command::add ("+attack", IN_AttackDown);
Cmd_AddCommand ("-attack", IN_AttackUp); command::add ("-attack", IN_AttackUp);
Cmd_AddCommand ("+use", IN_UseDown); command::add ("+use", IN_UseDown);
Cmd_AddCommand ("-use", IN_UseUp); command::add ("-use", IN_UseUp);
Cmd_AddCommand ("+jump", IN_JumpDown); command::add ("+jump", IN_JumpDown);
Cmd_AddCommand ("-jump", IN_JumpUp); command::add ("-jump", IN_JumpUp);
Cmd_AddCommand ("impulse", IN_Impulse); command::add ("impulse", IN_Impulse);
Cmd_AddCommand ("+klook", IN_KLookDown); command::add ("+klook", IN_KLookDown);
Cmd_AddCommand ("-klook", IN_KLookUp); command::add ("-klook", IN_KLookUp);
Cmd_AddCommand ("+mlook", IN_MLookDown); command::add ("+mlook", IN_MLookDown);
Cmd_AddCommand ("-mlook", IN_MLookUp); command::add ("-mlook", IN_MLookUp);
} }
+52 -52
View File
@@ -28,27 +28,27 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// references them even when on a unix system. // references them even when on a unix system.
// these two are not intended to be set directly // these two are not intended to be set directly
cvar_t cl_name = {"_cl_name", "player", CVAR_ARCHIVE}; convar cl_name{"_cl_name", "player", {.archive = true}};
cvar_t cl_color = {"_cl_color", "0", CVAR_ARCHIVE}; convar cl_color{"_cl_color", "0", {.archive = true}};
cvar_t cl_shownet = {"cl_shownet","0",CVAR_NONE}; // can be 0, 1, or 2 convar cl_shownet{"cl_shownet","0"}; // can be 0, 1, or 2
cvar_t cl_nolerp = {"cl_nolerp","0",CVAR_NONE}; convar cl_nolerp{"cl_nolerp","0"};
cvar_t cfg_unbindall = {"cfg_unbindall", "1", CVAR_ARCHIVE}; convar cfg_unbindall{"cfg_unbindall", "1", {.archive = true}};
cvar_t lookspring = {"lookspring","0", CVAR_ARCHIVE}; convar lookspring{"lookspring","0", {.archive = true}};
cvar_t lookstrafe = {"lookstrafe","0", CVAR_ARCHIVE}; convar lookstrafe{"lookstrafe","0", {.archive = true}};
cvar_t sensitivity = {"sensitivity","3", CVAR_ARCHIVE}; convar sensitivity{"sensitivity","3", {.archive = true}};
cvar_t m_pitch = {"m_pitch","0.022", CVAR_ARCHIVE}; convar m_pitch{"m_pitch","0.022", {.archive = true}};
cvar_t m_yaw = {"m_yaw","0.022", CVAR_ARCHIVE}; convar m_yaw{"m_yaw","0.022", {.archive = true}};
cvar_t m_forward = {"m_forward","1", CVAR_ARCHIVE}; convar m_forward{"m_forward","1", {.archive = true}};
cvar_t m_side = {"m_side","0.8", CVAR_ARCHIVE}; convar m_side{"m_side","0.8", {.archive = true}};
cvar_t cl_maxpitch = {"cl_maxpitch", "90", CVAR_ARCHIVE}; //johnfitz -- variable pitch clamping convar cl_maxpitch{"cl_maxpitch", "90", {.archive = true}}; //johnfitz -- variable pitch clamping
cvar_t cl_minpitch = {"cl_minpitch", "-90", CVAR_ARCHIVE}; //johnfitz -- variable pitch clamping convar cl_minpitch{"cl_minpitch", "-90", {.archive = true}}; //johnfitz -- variable pitch clamping
cvar_t cl_startdemos = {"cl_startdemos", "1", CVAR_ARCHIVE}; convar cl_startdemos{"cl_startdemos", "1", {.archive = true}};
client_static_t cls; client_static_t cls;
client_state_t cl; client_state_t cl;
@@ -63,7 +63,7 @@ int cl_max_edicts; //johnfitz -- only changes when new map loads
int cl_numvisedicts; int cl_numvisedicts;
entity_t *cl_visedicts[MAX_VISEDICTS]; entity_t *cl_visedicts[MAX_VISEDICTS];
extern cvar_t r_lerpmodels, r_lerpmove; //johnfitz extern convar r_lerpmodels, r_lerpmove; //johnfitz
/* /*
===================== =====================
@@ -651,13 +651,13 @@ int CL_ReadFromServer (void)
if (cl_numvisedicts > 256 && dev_peakstats.visedicts <= 256) if (cl_numvisedicts > 256 && dev_peakstats.visedicts <= 256)
Con_DWarning ("%i visedicts exceeds standard limit of 256 (max = %d).\n", cl_numvisedicts, MAX_VISEDICTS); Con_DWarning ("%i visedicts exceeds standard limit of 256 (max = %d).\n", cl_numvisedicts, MAX_VISEDICTS);
dev_stats.visedicts = cl_numvisedicts; dev_stats.visedicts = cl_numvisedicts;
dev_peakstats.visedicts = q_max(cl_numvisedicts, dev_peakstats.visedicts); dev_peakstats.visedicts = std::max(cl_numvisedicts, dev_peakstats.visedicts);
//temp entities //temp entities
if (num_temp_entities > 64 && dev_peakstats.tempents <= 64) if (num_temp_entities > 64 && dev_peakstats.tempents <= 64)
Con_DWarning ("%i tempentities exceeds standard limit of 64 (max = %d).\n", num_temp_entities, MAX_TEMP_ENTITIES); Con_DWarning ("%i tempentities exceeds standard limit of 64 (max = %d).\n", num_temp_entities, MAX_TEMP_ENTITIES);
dev_stats.tempents = num_temp_entities; dev_stats.tempents = num_temp_entities;
dev_peakstats.tempents = q_max(num_temp_entities, dev_peakstats.tempents); dev_peakstats.tempents = std::max(num_temp_entities, dev_peakstats.tempents);
//beams //beams
for (i=0, b=cl_beams ; i< MAX_BEAMS ; i++, b++) for (i=0, b=cl_beams ; i< MAX_BEAMS ; i++, b++)
@@ -666,7 +666,7 @@ int CL_ReadFromServer (void)
if (num_beams > 24 && dev_peakstats.beams <= 24) if (num_beams > 24 && dev_peakstats.beams <= 24)
Con_DWarning ("%i beams exceeded standard limit of 24 (max = %d).\n", num_beams, MAX_BEAMS); Con_DWarning ("%i beams exceeded standard limit of 24 (max = %d).\n", num_beams, MAX_BEAMS);
dev_stats.beams = num_beams; dev_stats.beams = num_beams;
dev_peakstats.beams = q_max(num_beams, dev_peakstats.beams); dev_peakstats.beams = std::max(num_beams, dev_peakstats.beams);
//dlights //dlights
for (i=0, l=cl_dlights ; i<MAX_DLIGHTS ; i++, l++) for (i=0, l=cl_dlights ; i<MAX_DLIGHTS ; i++, l++)
@@ -675,7 +675,7 @@ int CL_ReadFromServer (void)
if (num_dlights > 32 && dev_peakstats.dlights <= 32) if (num_dlights > 32 && dev_peakstats.dlights <= 32)
Con_DWarning ("%i dlights exceeded standard limit of 32 (max = %d).\n", num_dlights, MAX_DLIGHTS); Con_DWarning ("%i dlights exceeded standard limit of 32 (max = %d).\n", num_dlights, MAX_DLIGHTS);
dev_stats.dlights = num_dlights; dev_stats.dlights = num_dlights;
dev_peakstats.dlights = q_max(num_dlights, dev_peakstats.dlights); dev_peakstats.dlights = std::max(num_dlights, dev_peakstats.dlights);
//johnfitz //johnfitz
@@ -798,44 +798,44 @@ void CL_Init (void)
CL_InitInput (); CL_InitInput ();
CL_InitTEnts (); CL_InitTEnts ();
Cvar_RegisterVariable (&cl_name); cl_name.inscribe();
Cvar_RegisterVariable (&cl_color); cl_color.inscribe();
Cvar_RegisterVariable (&cl_upspeed); cl_upspeed.inscribe();
Cvar_RegisterVariable (&cl_forwardspeed); cl_forwardspeed.inscribe();
Cvar_RegisterVariable (&cl_backspeed); cl_backspeed.inscribe();
Cvar_RegisterVariable (&cl_sidespeed); cl_sidespeed.inscribe();
Cvar_RegisterVariable (&cl_movespeedkey); cl_movespeedkey.inscribe();
Cvar_RegisterVariable (&cl_yawspeed); cl_yawspeed.inscribe();
Cvar_RegisterVariable (&cl_pitchspeed); cl_pitchspeed.inscribe();
Cvar_RegisterVariable (&cl_anglespeedkey); cl_anglespeedkey.inscribe();
Cvar_RegisterVariable (&cl_shownet); cl_shownet.inscribe();
Cvar_RegisterVariable (&cl_nolerp); cl_nolerp.inscribe();
Cvar_RegisterVariable (&lookspring); lookspring.inscribe();
Cvar_RegisterVariable (&lookstrafe); lookstrafe.inscribe();
Cvar_RegisterVariable (&sensitivity); sensitivity.inscribe();
Cvar_RegisterVariable (&cl_alwaysrun); cl_alwaysrun.inscribe();
Cvar_RegisterVariable (&m_pitch); m_pitch.inscribe();
Cvar_RegisterVariable (&m_yaw); m_yaw.inscribe();
Cvar_RegisterVariable (&m_forward); m_forward.inscribe();
Cvar_RegisterVariable (&m_side); m_side.inscribe();
Cvar_RegisterVariable (&cfg_unbindall); cfg_unbindall.inscribe();
Cvar_RegisterVariable (&cl_maxpitch); //johnfitz -- variable pitch clamping cl_maxpitch.inscribe(); //johnfitz -- variable pitch clamping
Cvar_RegisterVariable (&cl_minpitch); //johnfitz -- variable pitch clamping cl_minpitch.inscribe(); //johnfitz -- variable pitch clamping
Cvar_RegisterVariable (&cl_startdemos); cl_startdemos.inscribe();
Cmd_AddCommand ("entities", CL_PrintEntities_f); command::add ("entities", CL_PrintEntities_f);
Cmd_AddCommand ("disconnect", CL_Disconnect_f); command::add ("disconnect", CL_Disconnect_f);
Cmd_AddCommand ("record", CL_Record_f); command::add ("record", CL_Record_f);
Cmd_AddCommand ("stop", CL_Stop_f); command::add ("stop", CL_Stop_f);
Cmd_AddCommand ("playdemo", CL_PlayDemo_f); command::add ("playdemo", CL_PlayDemo_f);
Cmd_AddCommand ("timedemo", CL_TimeDemo_f); command::add ("timedemo", CL_TimeDemo_f);
Cmd_AddCommand ("tracepos", CL_Tracepos_f); //johnfitz command::add ("tracepos", CL_Tracepos_f); //johnfitz
Cmd_AddCommand ("viewpos", CL_Viewpos_f); //johnfitz command::add ("viewpos", CL_Viewpos_f); //johnfitz
} }
+3 -3
View File
@@ -1067,7 +1067,7 @@ void CL_ParseServerMessage(void) {
cl_lightstyle[i].peak = 'a'; cl_lightstyle[i].peak = 'a';
for (j = 0; j < cl_lightstyle[i].length; j++) { for (j = 0; j < cl_lightstyle[i].length; j++) {
total += cl_lightstyle[i].map[j] - 'a'; total += cl_lightstyle[i].map[j] - 'a';
cl_lightstyle[i].peak = q_max(cl_lightstyle[i].peak, cl_lightstyle[i].map[j]); cl_lightstyle[i].peak = std::max(cl_lightstyle[i].peak, cl_lightstyle[i].map[j]);
} }
cl_lightstyle[i].average = total / cl_lightstyle[i].length + 'a'; cl_lightstyle[i].average = total / cl_lightstyle[i].length + 'a';
} else } else
@@ -1214,7 +1214,7 @@ void CL_ParseServerMessage(void) {
break; break;
case svc_sellscreen: case svc_sellscreen:
Cmd_ExecuteString("help", src_command); command::execute_string("help", command::source::command);
break; break;
//johnfitz -- new svc types //johnfitz -- new svc types
@@ -1223,7 +1223,7 @@ void CL_ParseServerMessage(void) {
break; break;
case svc_bf: case svc_bf:
Cmd_ExecuteString("bf", src_command); command::execute_string("bf", command::source::command);
break; break;
case svc_fog: case svc_fog:
+25 -25
View File
@@ -230,41 +230,41 @@ typedef struct
// //
// cvars // cvars
// //
extern cvar_t cl_name; extern convar cl_name;
extern cvar_t cl_color; extern convar cl_color;
extern cvar_t cl_upspeed; extern convar cl_upspeed;
extern cvar_t cl_forwardspeed; extern convar cl_forwardspeed;
extern cvar_t cl_backspeed; extern convar cl_backspeed;
extern cvar_t cl_sidespeed; extern convar cl_sidespeed;
extern cvar_t cl_movespeedkey; extern convar cl_movespeedkey;
extern cvar_t cl_yawspeed; extern convar cl_yawspeed;
extern cvar_t cl_pitchspeed; extern convar cl_pitchspeed;
extern cvar_t cl_anglespeedkey; extern convar cl_anglespeedkey;
extern cvar_t cl_alwaysrun; // QuakeSpasm extern convar cl_alwaysrun; // QuakeSpasm
extern cvar_t cl_autofire; extern convar cl_autofire;
extern cvar_t cl_shownet; extern convar cl_shownet;
extern cvar_t cl_nolerp; extern convar cl_nolerp;
extern cvar_t cfg_unbindall; extern convar cfg_unbindall;
extern cvar_t cl_pitchdriftspeed; extern convar cl_pitchdriftspeed;
extern cvar_t lookspring; extern convar lookspring;
extern cvar_t lookstrafe; extern convar lookstrafe;
extern cvar_t sensitivity; extern convar sensitivity;
extern cvar_t m_pitch; extern convar m_pitch;
extern cvar_t m_yaw; extern convar m_yaw;
extern cvar_t m_forward; extern convar m_forward;
extern cvar_t m_side; extern convar m_side;
extern cvar_t cl_startdemos; extern convar cl_startdemos;
#define MAX_TEMP_ENTITIES 256 //johnfitz -- was 64 #define MAX_TEMP_ENTITIES 256 //johnfitz -- was 64
@@ -368,7 +368,7 @@ void CL_SignonReply (void);
// //
// chase // chase
// //
extern cvar_t chase_active; extern convar chase_active;
void Chase_Init (void); void Chase_Init (void);
void TraceLine (vec3_t start, vec3_t end, vec3_t impact); void TraceLine (vec3_t start, vec3_t end, vec3_t impact);
+465 -644
View File
File diff suppressed because it is too large Load Diff
+50 -30
View File
@@ -20,8 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef _QUAKE_CMD_H #pragma once
#define _QUAKE_CMD_H
// cmd.h -- Command buffer and command execution // cmd.h -- Command buffer and command execution
@@ -72,56 +71,77 @@ not apropriate.
typedef void (*xcommand_t) (void); typedef void (*xcommand_t) (void);
typedef enum
{
src_client, // came in over a net connection as a clc_stringcmd
// host_client will be valid during this state.
src_command // from the command buffer
} cmd_source_t;
extern cmd_source_t cmd_source;
void Cmd_Init (void); namespace command {
enum class source {
client,
command
};
extern source last_source;
struct alias {
std::string name;
std::string value;
};
struct definition {
std::string name{};
xcommand_t func{nullptr};
definition(const std::string &name, const xcommand_t func) {
this->name = name;
this->func = func;
}
};
using definition_view = std::ranges::elements_view<std::ranges::ref_view<std::map<std::string, definition, std::less<>>>, 1>;
using alias_view = std::ranges::elements_view<std::ranges::ref_view<std::map<std::string, alias, std::less<>>>, 1>;
void init();
void add(const std::string &name, xcommand_t cmd);
std::optional<std::string> complete(const std::string &partial);
bool exists(std::string_view lookup);
int argc();
std::optional<std::string> argv(int arg);
std::string args();
int check_parm(const std::string &parm);
void tokenize_string(const std::string &text);
void execute_string(const std::string &text, source src);
void forward_to_server();
definition_view get_commands();
alias_view get_aliases();
}
void Cmd_AddCommand (const char *cmd_name, xcommand_t function);
// called by the init functions of other parts of the program to // called by the init functions of other parts of the program to
// register commands and functions to call for them. // register commands and functions to call for them.
// The cmd_name is referenced later, so it should not be in temp memory // The cmd_name is referenced later, so it should not be in temp memory
qboolean Cmd_Exists (const char *cmd_name);
// used by the cvar code to check for cvar / command name overlap // used by the cvar code to check for cvar / command name overlap
const char *Cmd_CompleteCommand (const char *partial);
// attempts to match a partial command for automatic command line completion // attempts to match a partial command for automatic command line completion
// returns NULL if nothing fits // returns NULL if nothing fits
int Cmd_Argc (void);
const char *Cmd_Argv (int arg);
const char *Cmd_Args (void);
// The functions that execute commands get their parameters with these
// functions. Cmd_Argv () will return an empty string, not a NULL
// if arg > argc, so string operations are allways safe.
int Cmd_CheckParm (const char *parm);
// Returns the position (1 to argc-1) in the command's argument list // Returns the position (1 to argc-1) in the command's argument list
// where the given parameter apears, or 0 if not present // where the given parameter apears, or 0 if not present
void Cmd_TokenizeString (const char *text);
// Takes a null terminated string. Does not need to be /n terminated.
// breaks the string up into arg tokens.
void Cmd_ExecuteString (const char *text, cmd_source_t src);
// Parses a single line of text into arguments and tries to execute it. // Parses a single line of text into arguments and tries to execute it.
// The text can come from the command buffer, a remote client, or stdin. // The text can come from the command buffer, a remote client, or stdin.
void Cmd_ForwardToServer (void);
// adds the current command line as a clc_stringcmd to the client message. // adds the current command line as a clc_stringcmd to the client message.
// things like godmode, noclip, etc, are commands directed to the server, // things like godmode, noclip, etc, are commands directed to the server,
// so when they are typed in at the console, they will need to be forwarded. // so when they are typed in at the console, they will need to be forwarded.
void Cmd_Print (const char *text);
// used by command functions to send output to either the graphics console or // used by command functions to send output to either the graphics console or
// passed as a print message to the client // passed as a print message to the client
#endif /* _QUAKE_CMD_H */
+410 -634
View File
File diff suppressed because it is too large Load Diff
+17 -43
View File
@@ -22,6 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef _Q_COMMON_H #ifndef _Q_COMMON_H
#define _Q_COMMON_H #define _Q_COMMON_H
#include "convar.hpp"
// comndef.h -- general definitions // comndef.h -- general definitions
@@ -57,10 +58,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define NO_COMMA #define NO_COMMA
#define IMPL_GENERIC_FUNCS(type, suffix) \ #define IMPL_GENERIC_FUNCS(type, suffix) \
static inline type q_min_##suffix (type a, type b) { \ static inline type std::min_##suffix (type a, type b) { \
return (a < b) ? a : b; \ return (a < b) ? a : b; \
} \ } \
static inline type q_max_##suffix (type a, type b) { \ static inline type std::max_##suffix (type a, type b) { \
return (a > b) ? a : b; \ return (a > b) ? a : b; \
} \ } \
static inline type clamp_##suffix (type minval, type val, type maxval) { \ static inline type clamp_##suffix (type minval, type val, type maxval) { \
@@ -69,30 +70,17 @@ static inline type clamp_##suffix (type minval, type val, type maxval) { \
GENERIC_TYPES (IMPL_GENERIC_FUNCS, NO_COMMA) GENERIC_TYPES (IMPL_GENERIC_FUNCS, NO_COMMA)
#define SELECT_Q_MIN(type, suffix) type: q_min_##suffix #define SELECT_std::min(type, suffix) type: std::min_##suffix
#define q_min(a, b) _Generic((a) + (b), GENERIC_TYPES (SELECT_Q_MIN, COMMA))(a, b) #define std::min(a, b) _Generic((a) + (b), GENERIC_TYPES (SELECT_std::min, COMMA))(a, b)
#define SELECT_Q_MAX(type, suffix) type: q_max_##suffix #define SELECT_std::max(type, suffix) type: std::max_##suffix
#define q_max(a, b) _Generic((a) + (b), GENERIC_TYPES (SELECT_Q_MAX, COMMA))(a, b) #define std::max(a, b) _Generic((a) + (b), GENERIC_TYPES (SELECT_std::max, COMMA))(a, b)
#define SELECT_CLAMP(type, suffix) type: clamp_##suffix #define SELECT_CLAMP(type, suffix) type: clamp_##suffix
#define CLAMP(minval, val, maxval) _Generic((minval) + (val) + (maxval), \ #define CLAMP(minval, val, maxval) _Generic((minval) + (val) + (maxval), \
GENERIC_TYPES (SELECT_CLAMP, COMMA))(minval, val, maxval) GENERIC_TYPES (SELECT_CLAMP, COMMA))(minval, val, maxval)
#elif defined(__GNUC__) #elif defined(__GNUC__)
/* min and max macros with type checking -- based on tyrquake. */
#define q_max(a,b) ({ \
const __typeof(a) a_ = (a); \
const __typeof(b) b_ = (b); \
(void)(&a_ == &b_); \
(a_ > b_) ? a_ : b_; \
})
#define q_min(a,b) ({ \
const __typeof(a) a_ = (a); \
const __typeof(b) b_ = (b); \
(void)(&a_ == &b_); \
(a_ < b_) ? a_ : b_; \
})
#define CLAMP(_minval, x, _maxval) ({ \ #define CLAMP(_minval, x, _maxval) ({ \
const __typeof(x) x_ = (x); \ const __typeof(x) x_ = (x); \
const __typeof(_minval) valmin_ = (_minval);\ const __typeof(_minval) valmin_ = (_minval);\
@@ -104,8 +92,8 @@ GENERIC_TYPES (IMPL_GENERIC_FUNCS, NO_COMMA)
}) })
#else #else
#define q_min(a, b) (((a) < (b)) ? (a) : (b)) #define std::min(a, b) (((a) < (b)) ? (a) : (b))
#define q_max(a, b) (((a) > (b)) ? (a) : (b)) #define std::max(a, b) (((a) > (b)) ? (a) : (b))
#define CLAMP(_minval, x, _maxval) \ #define CLAMP(_minval, x, _maxval) \
((x) < (_minval) ? (_minval) : \ ((x) < (_minval) ? (_minval) : \
(x) > (_maxval) ? (_maxval) : (x)) (x) > (_maxval) ? (_maxval) : (x))
@@ -237,17 +225,16 @@ extern int q_vsnprintf(char *str, size_t size, const char *format, va_list args)
//============================================================================ //============================================================================
extern char com_token[1024];
extern qboolean com_eof; extern qboolean com_eof;
typedef enum
{
CPE_NOTRUNC, // return parse error in case of overflow
CPE_ALLOWTRUNC // truncate com_token in case of overflow
} cpe_mode;
const char *COM_Parse (const char *data); namespace common {
const char *COM_ParseEx (const char *data, cpe_mode mode); std::optional<std::string> parse_token(std::istringstream &ss);
std::string parse_string_newline(std::istringstream &ss);
int parse_int_newline(std::istringstream &ss);
float parse_float_newline(std::istringstream &ss);
}
extern int com_argc; extern int com_argc;
@@ -358,19 +345,6 @@ byte *COM_LoadMallocFile (const char *path, unsigned int *path_id);
// Loads in "t" mode so CRLF to LF translation is performed on Windows. // Loads in "t" mode so CRLF to LF translation is performed on Windows.
byte *COM_LoadMallocFile_TextMode_OSPath (const char *path, long *len_out); byte *COM_LoadMallocFile_TextMode_OSPath (const char *path, long *len_out);
// Attempts to parse an int, followed by a newline.
// Returns advanced buffer position.
// Doesn't signal parsing failure, but this is not needed for savegame loading.
const char *COM_ParseIntNewline(const char *buffer, int *value);
// Attempts to parse a float followed by a newline.
// Returns advanced buffer position.
const char *COM_ParseFloatNewline(const char *buffer, float *value);
// Parse a string of non-whitespace into com_token, then tries to consume a
// newline. Returns advanced buffer position.
const char *COM_ParseStringNewline(const char *buffer);
#define FS_ENT_NONE (0) #define FS_ENT_NONE (0)
#define FS_ENT_FILE (1 << 0) #define FS_ENT_FILE (1 << 0)
@@ -403,7 +377,7 @@ char *FS_fgets(char *s, int size, fshandle_t *fh);
long FS_filelength (fshandle_t *fh); long FS_filelength (fshandle_t *fh);
extern struct cvar_s registered; extern convar registered;
extern qboolean standard_quake, rogue, hipnotic; extern qboolean standard_quake, rogue, hipnotic;
extern qboolean fitzmode; extern qboolean fitzmode;
/* if true, run in fitzquake mode disabling custom quakespasm hacks */ /* if true, run in fitzquake mode disabling custom quakespasm hacks */
+21 -37
View File
@@ -50,8 +50,8 @@ int con_current; // where next message will be printed
int con_x; // offset in current line for next print int con_x; // offset in current line for next print
char *con_text = NULL; char *con_text = NULL;
cvar_t con_notifytime = {"con_notifytime","3",CVAR_NONE}; //seconds convar con_notifytime{"con_notifytime","3"}; //seconds
cvar_t con_logcenterprint = {"con_logcenterprint", "1", CVAR_NONE}; //johnfitz convar con_logcenterprint{"con_logcenterprint", "1"}; //johnfitz
char con_lastcenterstring[1024]; //johnfitz char con_lastcenterstring[1024]; //johnfitz
@@ -78,8 +78,8 @@ const char *Con_Quakebar (int len)
static char bar[42]; static char bar[42];
int i; int i;
len = q_min(len, (int)sizeof(bar) - 2); len = std::min(len, (int)sizeof(bar) - 2);
len = q_min(len, con_linewidth); len = std::min(len, con_linewidth);
bar[0] = '\35'; bar[0] = '\35';
for (i = 1; i < len - 1; i++) for (i = 1; i < len - 1; i++)
@@ -331,14 +331,14 @@ void Con_Init (void)
Con_Printf ("Console initialized.\n"); Con_Printf ("Console initialized.\n");
Cvar_RegisterVariable (&con_notifytime); con_notifytime.inscribe();
Cvar_RegisterVariable (&con_logcenterprint); //johnfitz con_logcenterprint.inscribe(); //johnfitz
Cmd_AddCommand ("toggleconsole", Con_ToggleConsole_f); command::add ("toggleconsole", Con_ToggleConsole_f);
Cmd_AddCommand ("messagemode", Con_MessageMode_f); command::add ("messagemode", Con_MessageMode_f);
Cmd_AddCommand ("messagemode2", Con_MessageMode2_f); command::add ("messagemode2", Con_MessageMode2_f);
Cmd_AddCommand ("clear", Con_Clear_f); command::add ("clear", Con_Clear_f);
Cmd_AddCommand ("condump", Con_Dump_f); //johnfitz command::add ("condump", Con_Dump_f); //johnfitz
con_initialized = true; con_initialized = true;
} }
@@ -658,7 +658,7 @@ void Con_CenterPrintf (int linewidth, const char *fmt, ...)
q_vsnprintf (msg, sizeof(msg), fmt, argptr); q_vsnprintf (msg, sizeof(msg), fmt, argptr);
va_end (argptr); va_end (argptr);
linewidth = q_min(linewidth, con_linewidth); linewidth = std::min(linewidth, con_linewidth);
for (src = msg; *src; ) for (src = msg; *src; )
{ {
dst = line; dst = line;
@@ -727,21 +727,7 @@ tab_t *tablist;
//defs from elsewhere //defs from elsewhere
extern qboolean keydown[256]; extern qboolean keydown[256];
typedef struct cmd_function_s
{
struct cmd_function_s *next;
const char *name;
xcommand_t function;
} cmd_function_t;
extern cmd_function_t *cmd_functions;
#define MAX_ALIAS_NAME 32 #define MAX_ALIAS_NAME 32
typedef struct cmdalias_s
{
struct cmdalias_s *next;
char name[MAX_ALIAS_NAME];
char *value;
} cmdalias_t;
extern cmdalias_t *cmd_alias;
/* /*
============ ============
@@ -897,8 +883,6 @@ BuildTabList -- johnfitz
*/ */
void BuildTabList (const char *partial) void BuildTabList (const char *partial)
{ {
cmdalias_t *alias;
cmd_function_t *cmd;
int len; int len;
tablist = NULL; tablist = NULL;
@@ -907,17 +891,17 @@ void BuildTabList (const char *partial)
bash_partial[0] = 0; bash_partial[0] = 0;
bash_singlematch = 1; bash_singlematch = 1;
for (auto cvar : std::ranges::views::values(CLIENT_VARIABLES)) for (const auto cvar : convar::get_variables())
if (!Q_strncmp (partial, cvar->name, len)) if (!Q_strncmp (partial, cvar->name.c_str(), len))
AddToTabList (cvar->name, "cvar"); AddToTabList (cvar->name.c_str(), "cvar");
for (cmd=cmd_functions ; cmd ; cmd=cmd->next) for (const auto &ccmd : command::get_commands())
if (!Q_strncmp (partial,cmd->name, len)) if (!Q_strncmp (partial,ccmd.name.c_str(), len))
AddToTabList (cmd->name, "command"); AddToTabList (ccmd.name.c_str(), "command");
for (alias=cmd_alias ; alias ; alias=alias->next) for (const auto &alias : command::get_aliases())
if (!Q_strncmp (partial, alias->name, len)) if (!Q_strncmp (partial, alias.name.c_str(), len))
AddToTabList (alias->name, "alias"); AddToTabList (alias.name.c_str(), "alias");
} }
/* /*
+540
View File
@@ -0,0 +1,540 @@
/*
Copyright (C) 1996-2001 Id Software, Inc.
Copyright (C) 2002-2009 John Fitzgibbons and others
Copyright (C) 2010-2014 QuakeSpasm developers
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// cvar.c -- dynamic variable tracking
#include "quakedef.hpp"
#include <map>
#include <string>
#include <ranges>
#include <memory>
#include <cstring>
#include <format>
std::map<std::string, convar *> CLIENT_VARIABLES{};
//==============================================================================
//
// USER COMMANDS
//
//==============================================================================
/*
============
Cvar_List_f -- johnfitz
============
*/
void Cvar_List_f() {
convar *cvar;
const char *partial;
int len, count;
if (command::argc() > 1) {
partial = command::argv(1)->c_str();
len = Q_strlen(partial);
} else {
partial = NULL;
len = 0;
}
count = 0;
for (const auto &[name, var]: CLIENT_VARIABLES) {
if (partial && Q_strncmp(partial, name.c_str(), len)) {
continue;
}
Con_SafePrintf("%s%s %s \"%s\"\n",
var->flags.archive ? "*" : " ",
var->flags.notify ? "s" : " ",
name.c_str(),
var->string);
count++;
}
Con_SafePrintf("%i cvars", count);
if (partial) {
Con_SafePrintf(" beginning with \"%s\"", partial);
}
Con_SafePrintf("\n");
}
/*
============
Cvar_Inc_f -- johnfitz
============
*/
void Cvar_Inc_f(void) {
switch (command::argc()) {
default:
case 1:
Con_Printf("inc <cvar> [amount] : increment cvar\n");
break;
case 2:
convar::set_value(*command::argv(1), convar::variable_value(*command::argv(1)).value_or(0.0) + 1);
break;
case 3:
convar::set_value(*command::argv(1), convar::variable_value(*command::argv(1)).value_or(0.0) + Q_atof(command::argv(2)->c_str()));
break;
}
}
/*
============
Cvar_Toggle_f -- johnfitz
============
*/
void Cvar_Toggle_f() {
switch (command::argc()) {
default:
case 1:
Con_Printf("toggle <cvar> : toggle cvar\n");
break;
case 2:
if (convar::variable_value(*command::argv(1)).value_or(0.0) != 0.0)
convar::set(*command::argv(1), "0");
else
convar::set(*command::argv(1), "1");
break;
}
}
/*
============
Cvar_Cycle_f -- johnfitz
============
*/
void Cvar_Cycle_f() {
int i;
if (command::argc() < 3) {
Con_Printf("cycle <cvar> <value list>: cycle cvar through a list of values\n");
return;
}
//loop through the args until you find one that matches the current cvar value.
//yes, this will get stuck on a list that contains the same value twice.
//it's not worth dealing with, and i'm not even sure it can be dealt with.
for (i = 2; i < command::argc(); i++) {
//zero is assumed to be a string, even though it could actually be zero. The worst case
//is that the first time you call this command, it won't match on zero when it should, but after that,
//it will be comparing strings that all had the same source (the user) so it will work.
if (Q_atof(command::argv(i)->c_str()) == 0) {
if (!strcmp(command::argv(i)->c_str(), convar::variable_string(*command::argv(1)).value_or("").c_str()))
break;
} else {
if (Q_atof(command::argv(i)->c_str()) == convar::variable_value(*command::argv(1)).value_or(0.0))
break;
}
}
if (i == command::argc())
convar::set(*command::argv(1), *command::argv(2)); // no match
else if (i + 1 == command::argc())
convar::set(*command::argv(1), *command::argv(2)); // matched last value in list
else
convar::set(*command::argv(1), *command::argv(i + 1)); // matched earlier in list
}
/*
============
Cvar_Reset_f -- johnfitz
============
*/
void Cvar_Reset_f() {
switch (command::argc()) {
default:
case 1:
Con_Printf("reset <cvar> : reset cvar to default\n");
break;
case 2:
convar::reset(*command::argv(1));
break;
}
}
/*
============
Cvar_ResetAll_f -- johnfitz
============
*/
void Cvar_ResetAll_f(void) {
convar *var;
for (auto name: std::views::keys(CLIENT_VARIABLES))
convar::reset(name);
}
/*
============
Cvar_ResetCfg_f -- QuakeSpasm
============
*/
void Cvar_ResetCfg_f() {
for (const auto &var: std::views::values(CLIENT_VARIABLES))
if (var->flags.archive) convar::reset(var->name);
}
//==============================================================================
//
// INIT
//
//==============================================================================
/*
============
Cvar_Init -- johnfitz
============
*/
void Cvar_Init() {
command::add("cvarlist", Cvar_List_f);
command::add("toggle", Cvar_Toggle_f);
command::add("cycle", Cvar_Cycle_f);
command::add("inc", Cvar_Inc_f);
command::add("reset", Cvar_Reset_f);
command::add("resetall", Cvar_ResetAll_f);
command::add("resetcfg", Cvar_ResetCfg_f);
}
std::optional<convar *> convar::find_var(const std::string_view &desired) {
for (auto &[name, var]: CLIENT_VARIABLES) {
if (name == desired)
return var;
}
return std::nullopt;
}
std::optional<convar *> convar::find_var_after(const std::optional<std::string> &prev_name,
const std::optional<cvar_flags> with_flags) {
auto iter = CLIENT_VARIABLES.begin();
if (prev_name.has_value()) {
iter = CLIENT_VARIABLES.find(prev_name.value());
if (iter == CLIENT_VARIABLES.end())
return std::nullopt;
++iter;
}
// search for the next cvar matching the needed flags
while (iter != CLIENT_VARIABLES.end()) {
if (!with_flags.has_value() || iter->second->flags.matches_mask(with_flags.value()))
break;
++iter;
}
if (iter != CLIENT_VARIABLES.end()) {
return iter->second;
}
return std::nullopt;
}
void convar::lock_var(const std::string_view &name) {
if (const auto var = find_var(name); var.has_value())
var.value()->flags.locked = true;
}
void convar::unlock_var(const std::string_view &name) {
if (const auto var = find_var(name); var.has_value())
var.value()->flags.locked = false;
}
void convar::unlock_all() {
for (const auto &var: std::views::values(CLIENT_VARIABLES)) {
var->flags.locked = false;
}
}
/**
* Gets a floating-point representation of the `string` value of the `convar` matching `name`.
*
* @param name The name of the variable to retreive
* @return The value of the variable matching `name`, or `std::nullopt` if a variable with
* that name cannot be found.
*/
std::optional<float> convar::variable_value(const std::string_view &name) {
const auto var = find_var(name);
if (!var.has_value())
return std::nullopt;
return std::strtof(var.value()->string, nullptr);
}
/**
* Gets the `string` value of the `convar` matching `name`.
*
* @param name The name of the variable to retreive
* @return The value of the variable matching `name`, or `std::nullopt` if a variable with
* that name cannot be found.
*/
std::optional<std::string> convar::variable_string(const std::string_view &name) {
const auto var = find_var(name);
if (!var.has_value())
return std::nullopt;
return var.value()->string;
}
/**
* Autocompletes the name of a `convar` starting with `partial`.
*
* @param partial Partial name of a variable to retrieve
* @return The full name of the first variable beginning with `partial`, or `std::nullopt` if
* no matching variable is found.
*/
std::optional<std::string_view> convar::complete_variable(const std::string_view &partial) {
if (!partial.empty())
return std::nullopt;
// check functions
for (const auto &name: CLIENT_VARIABLES | std::views::keys) {
if (name.starts_with(name))
return name;
}
return std::nullopt;
}
/**
* Resets a `convar`s `string` to its `default_string` value.
*
* @param name Name of the convar to reset
*/
void convar::reset(const std::string &name) {
if (const auto var = find_var(name); !var.has_value())
Con_Printf("variable \"%s\" not found\n", name.c_str());
else
var.value()->set(var.value()->default_string);
}
void convar::set(const std::string &new_value) {
if (this->flags.rom || this->flags.locked)
return;
if (!(this->flags.registered))
return;
if (!this->string)
this->string = Z_Strdup(new_value.c_str());
else {
if (!strcmp(this->string, new_value.c_str()))
return; // no change
this->flags.changed = true;
const std::size_t len = new_value.length();
if (len != Q_strlen(this->string)) {
Z_Free((void *) this->string);
this->string = (char *) Z_Malloc(len + 1);
}
memcpy((char *) this->string, new_value.c_str(), len + 1);
}
this->value = Q_atof(this->string);
//johnfitz -- save initial value for "reset" command
if (!this->default_string)
this->default_string = Z_Strdup(this->string);
//johnfitz -- during initialization, update default too
else if (!host_initialized) {
// Sys_Printf("changing default of %s: %s -> %s\n",
// this->name, this->default_string, this->string);
Z_Free((void *) this->default_string);
this->default_string = Z_Strdup(this->string);
}
//johnfitz
if (this->callback)
this->callback(this);
}
void convar::set_value(const float new_value) {
std::string val;
if (new_value == static_cast<float>(static_cast<int>(new_value)))
val = std::format("{:d}", static_cast<int>(new_value));
else {
val = std::format("{:f}", new_value);
// kill trailing zeroes
val.erase(val.find_last_not_of('0') + 1, std::string::npos);
}
this->set(val);
}
/*
============
Cvar_Set
============
*/
void convar::set(const std::string &name, const std::string &value) {
const auto var = find_var(name);
if (!var.has_value()) {
// there is an error in C code if this happens
Con_Printf("Cvar_Set: variable %s not found\n", name.c_str());
return;
}
var.value()->set(value);
}
/*
============
convar::set_value
============
*/
void convar::set_value(const std::string &name, const float new_value) {
std::string val;
if (new_value == static_cast<float>(static_cast<int>(new_value)))
val = std::format("{:d}", static_cast<int>(new_value));
else {
val = std::format("{:f}", new_value);
// kill trailing zeroes
val.erase(val.find_last_not_of('0') + 1, std::string::npos);
}
set(name, val);
}
/*
============
Cvar_SetROM
============
*/
void convar::set_rom(const std::string_view &name, const std::string value) {
if (const auto var = find_var(name); var.has_value()) {
var.value()->flags.rom = false;
var.value()->set(value);
var.value()->flags.rom = true;
}
}
void convar::set_value_rom(const std::string_view &name, const float value) {
if (const auto var = find_var(name); var.has_value()) {
var.value()->flags.rom = false;
var.value()->set_value(value);
var.value()->flags.rom = true;
}
}
convar_view convar::get_variables() {
return std::ranges::views::values(CLIENT_VARIABLES);
}
convar::convar(const std::string_view name, const char *str) : convar(name, str, {}) {
}
convar::convar(const std::string_view name, const char *str, const cvar_flags flags) {
this->name = name;
this->string = str;
this->flags = flags;
}
/**
* Adds a freestanding variable to the variable list.
*/
void convar::inscribe() {
char value[512];
convar *cursor, *prev; //johnfitz -- sorted list insert
// first check to see if it has already been defined
if (find_var(this->name)) {
Con_Printf("Can't register variable %s, already defined\n", this->name.c_str());
return;
}
// check for overlap with a command
if (command::exists(this->name)) {
Con_Printf("Cvar_RegisterVariable: %s is a command\n", this->name.c_str());
return;
}
CLIENT_VARIABLES.emplace(std::string(this->name), this);
//johnfitz
this->flags.registered = true;
// copy the value off, because future sets will Z_Free it
std::strncpy(value, this->string, sizeof(value));
this->string = nullptr;
this->default_string = nullptr;
if (!this->flags.callback)
this->callback = nullptr;
// set it through the function to be consistent
const bool set_rom = (this->flags.rom);
this->flags.rom = false;
this->set(value);
if (set_rom)
this->flags.rom = true;
}
/**
* Set a callback function for the variable
* @param func Callback to be used (or `nullptr` to disable to callback).
*/
void convar::set_callback(const cvarcallback_t func) {
this->callback = func;
this->flags.callback = func != nullptr;
}
/*
============
Cvar_Command
Handles variable inspection and changing from the console
============
*/
qboolean Cvar_Command() {
// check variables
auto var = convar::find_var(command::argv(0).value_or(""));
if (!var.has_value())
return false;
// perform a variable print or set
if (command::argc() == 1) {
Con_Printf("\"%s\" is \"%s\"\n", var.value()->name.c_str(), var.value()->string);
return true;
}
convar::set(var.value()->name, *command::argv(1));
return true;
}
/*
============
Cvar_WriteVariables
Writes lines containing "set variable value" for all variables
with the archive flag set to true.
============
*/
void Cvar_WriteVariables(FILE *f) {
for (const auto &[name, var]: CLIENT_VARIABLES) {
if (var->flags.archive)
fprintf(f, "%s \"%s\"\n", name.c_str(), var->string);
}
}
+154
View File
@@ -0,0 +1,154 @@
/*
Copyright (C) 1996-2001 Id Software, Inc.
Copyright (C) 2002-2009 John Fitzgibbons and others
Copyright (C) 2010-2014 QuakeSpasm developers
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#pragma once
/*
cvar_t variables are used to hold scalar or string variables that can
be changed or displayed at the console or prog code as well as accessed
directly in C code.
it is sufficient to initialize a cvar_t with just the first two fields,
or you can add a ,true flag for variables that you want saved to the
configuration file when the game is quit:
cvar_t r_draworder = {"r_draworder","1"};
cvar_t scr_screensize = {"screensize","1",true};
Cvars must be registered before use, or they will have a 0 value instead
of the float interpretation of the string.
Generally, all cvar_t declarations should be registered in the apropriate
init function before any console commands are executed:
host_framerate.inscribe();
C code usually just references a cvar in place:
if ( r_draworder.value )
It could optionally ask for the value to be looked up for a string name:
if (Cvar_VariableValue ("r_draworder"))
Interpreted prog code can access cvars with the cvar(name) or
cvar_set (name, value) internal functions:
teamplay = cvar("teamplay");
cvar_set ("registered", "1");
The user can access cvars from the console in two ways:
r_draworder prints the current value
r_draworder 0 sets the current value to 0
Cvars are restricted from having the same names as commands to keep this
interface from being ambiguous.
*/
#include <map>
#include <optional>
#include <ranges>
#include "convar.hpp"
void Cvar_Init();
struct cvar_flags {
bool archive{false};
bool notify{false};
bool server_info{false};
bool user_info{false};
bool changed{false};
bool rom{false};
bool locked{false};
bool registered{false};
bool callback{false};
[[nodiscard]] bool matches_mask(const cvar_flags &rhs) const {
return (!rhs.archive || this->archive) &&
(!rhs.notify || this->notify) &&
(!rhs.server_info || this->server_info) &&
(!rhs.user_info || this->user_info) &&
(!rhs.changed || this->changed) &&
(!rhs.rom || this->rom) &&
(!rhs.locked || this->locked) &&
(!rhs.registered || this->registered) &&
(!rhs.callback || this->callback);
}
};
struct convar;
typedef void (*cvarcallback_t)(convar *);
using convar_view = std::ranges::elements_view<std::ranges::ref_view<std::map<std::string, convar *> >, 1>;
struct convar {
std::string name{};
const char *string{nullptr};
cvar_flags flags{};
float value{};
const char *default_string{nullptr}; //johnfitz -- remember defaults for reset function
cvarcallback_t callback{nullptr};
convar(std::string_view name, const char *str);
convar(std::string_view name, const char *str, cvar_flags flags);
void inscribe();
void set_callback(cvarcallback_t func);
void set(const std::string &new_value);
void set_value(float new_value);
static std::optional<convar *> find_var(const std::string_view &desired);
static std::optional<convar *> find_var_after(const std::optional<std::string> &prev_name,
std::optional<cvar_flags> with_flags);
static void reset(const std::string &name);
static void set(const std::string &name, const std::string &new_value);
static void set_value(const std::string &name, float new_value);
static std::optional<std::string_view> complete_variable(const std::string_view &partial);
static std::optional<float> variable_value(const std::string_view &name);
static std::optional<std::string> variable_string(const std::string_view &name);
static void lock_var(const std::string_view &name);
static void unlock_var(const std::string_view &name);
static void unlock_all();
static void set_rom(const std::string_view &name, std::string value);
static void set_value_rom(const std::string_view &name, float value);
static convar_view get_variables();
};
qboolean Cvar_Command(void);
void Cvar_WriteVariables(FILE *f);
-560
View File
@@ -1,560 +0,0 @@
/*
Copyright (C) 1996-2001 Id Software, Inc.
Copyright (C) 2002-2009 John Fitzgibbons and others
Copyright (C) 2010-2014 QuakeSpasm developers
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// cvar.c -- dynamic variable tracking
#include "quakedef.hpp"
#include <map>
#include <string>
#include <ranges>
#include <memory>
#include <cstring>
static cvar_t *cvar_vars;
static char cvar_null_string[] = "";
std::map<std::string, cvar_t* > CLIENT_VARIABLES{};
//==============================================================================
//
// USER COMMANDS
//
//==============================================================================
void Cvar_Reset(const std::string &name); //johnfitz
/*
============
Cvar_List_f -- johnfitz
============
*/
void Cvar_List_f() {
cvar_t *cvar;
const char *partial;
int len, count;
if (Cmd_Argc() > 1) {
partial = Cmd_Argv(1);
len = Q_strlen(partial);
} else {
partial = NULL;
len = 0;
}
count = 0;
for (const auto &[name, var]: CLIENT_VARIABLES) {
if (partial && Q_strncmp(partial, name.c_str(), len)) {
continue;
}
Con_SafePrintf("%s%s %s \"%s\"\n",
(var->flags & CVAR_ARCHIVE) ? "*" : " ",
(var->flags & CVAR_NOTIFY) ? "s" : " ",
name.c_str(),
var->string);
count++;
}
Con_SafePrintf("%i cvars", count);
if (partial) {
Con_SafePrintf(" beginning with \"%s\"", partial);
}
Con_SafePrintf("\n");
}
/*
============
Cvar_Inc_f -- johnfitz
============
*/
void Cvar_Inc_f(void) {
switch (Cmd_Argc()) {
default:
case 1:
Con_Printf("inc <cvar> [amount] : increment cvar\n");
break;
case 2:
Cvar_SetValue(Cmd_Argv(1), Cvar_VariableValue(Cmd_Argv(1)) + 1);
break;
case 3:
Cvar_SetValue(Cmd_Argv(1), Cvar_VariableValue(Cmd_Argv(1)) + Q_atof(Cmd_Argv(2)));
break;
}
}
/*
============
Cvar_Toggle_f -- johnfitz
============
*/
void Cvar_Toggle_f(void) {
switch (Cmd_Argc()) {
default:
case 1:
Con_Printf("toggle <cvar> : toggle cvar\n");
break;
case 2:
if (Cvar_VariableValue(Cmd_Argv(1)))
Cvar_Set(Cmd_Argv(1), "0");
else
Cvar_Set(Cmd_Argv(1), "1");
break;
}
}
/*
============
Cvar_Cycle_f -- johnfitz
============
*/
void Cvar_Cycle_f() {
int i;
if (Cmd_Argc() < 3) {
Con_Printf("cycle <cvar> <value list>: cycle cvar through a list of values\n");
return;
}
//loop through the args until you find one that matches the current cvar value.
//yes, this will get stuck on a list that contains the same value twice.
//it's not worth dealing with, and i'm not even sure it can be dealt with.
for (i = 2; i < Cmd_Argc(); i++) {
//zero is assumed to be a string, even though it could actually be zero. The worst case
//is that the first time you call this command, it won't match on zero when it should, but after that,
//it will be comparing strings that all had the same source (the user) so it will work.
if (Q_atof(Cmd_Argv(i)) == 0) {
if (!strcmp(Cmd_Argv(i), Cvar_VariableString(Cmd_Argv(1))))
break;
} else {
if (Q_atof(Cmd_Argv(i)) == Cvar_VariableValue(Cmd_Argv(1)))
break;
}
}
if (i == Cmd_Argc())
Cvar_Set(Cmd_Argv(1), Cmd_Argv(2)); // no match
else if (i + 1 == Cmd_Argc())
Cvar_Set(Cmd_Argv(1), Cmd_Argv(2)); // matched last value in list
else
Cvar_Set(Cmd_Argv(1), Cmd_Argv(i + 1)); // matched earlier in list
}
/*
============
Cvar_Reset_f -- johnfitz
============
*/
void Cvar_Reset_f() {
switch (Cmd_Argc()) {
default:
case 1:
Con_Printf("reset <cvar> : reset cvar to default\n");
break;
case 2:
Cvar_Reset(Cmd_Argv(1));
break;
}
}
/*
============
Cvar_ResetAll_f -- johnfitz
============
*/
void Cvar_ResetAll_f(void) {
cvar_t *var;
for (auto name: std::views::keys(CLIENT_VARIABLES))
Cvar_Reset(name);
}
/*
============
Cvar_ResetCfg_f -- QuakeSpasm
============
*/
void Cvar_ResetCfg_f() {
for (const auto &var: std::views::values(CLIENT_VARIABLES))
if (var->flags & CVAR_ARCHIVE) Cvar_Reset(var->name);
}
//==============================================================================
//
// INIT
//
//==============================================================================
/*
============
Cvar_Init -- johnfitz
============
*/
void Cvar_Init() {
Cmd_AddCommand("cvarlist", Cvar_List_f);
Cmd_AddCommand("toggle", Cvar_Toggle_f);
Cmd_AddCommand("cycle", Cvar_Cycle_f);
Cmd_AddCommand("inc", Cvar_Inc_f);
Cmd_AddCommand("reset", Cvar_Reset_f);
Cmd_AddCommand("resetall", Cvar_ResetAll_f);
Cmd_AddCommand("resetcfg", Cvar_ResetCfg_f);
}
//==============================================================================
//
// CVAR FUNCTIONS
//
//==============================================================================
/*
============
Cvar_FindVar
============
*/
std::optional<cvar_t *> Cvar_FindVar(const std::string &desired) {
for (auto &[name, var]: CLIENT_VARIABLES) {
if (name == desired)
return var;
}
return std::nullopt;
}
cvar_t *Cvar_FindVarAfter(const char *prev_name, unsigned int with_flags) {
// cvar_t *var;
//
// if (*prev_name)
// {
// var = Cvar_FindVar (prev_name);
// if (!var)
// return NULL;
// var = var->next;
// }
// else
// var = cvar_vars;
//
// // search for the next cvar matching the needed flags
// while (var)
// {
// if ((var->flags & with_flags) || !with_flags)
// break;
// var = var->next;
// }
// return var;
return nullptr; // TODO
}
/*
============
Cvar_LockVar
============
*/
void Cvar_LockVar(const std::string &name) {
if (const auto var = Cvar_FindVar(name); var.has_value())
var.value()->flags |= CVAR_LOCKED;
}
void Cvar_UnlockVar(const std::string &name) {
if (const auto var = Cvar_FindVar(name); var.has_value())
var.value()->flags &= ~CVAR_LOCKED;
}
void Cvar_UnlockAll() {
for (const auto &var: std::views::values(CLIENT_VARIABLES)) {
var->flags &= ~CVAR_LOCKED;
}
}
/*
============
Cvar_VariableValue
============
*/
float Cvar_VariableValue(const char *var_name) {
const auto var = Cvar_FindVar(var_name);
if (!var.has_value())
return 0;
return std::strtof(var.value()->string, nullptr);
}
/*
============
Cvar_VariableString
============
*/
const char *Cvar_VariableString(const char *var_name) {
const auto var = Cvar_FindVar(var_name);
if (!var.has_value())
return cvar_null_string;
return var.value()->string;
}
/*
============
Cvar_CompleteVariable
============
*/
std::optional<std::string_view> Cvar_CompleteVariable(const std::string_view &partial) {
if (!partial.empty())
return std::nullopt;
// check functions
for (const auto &name: CLIENT_VARIABLES | std::views::keys) {
if (name.contains(name))
return name;
}
return std::nullopt;
}
/*
============
Cvar_Reset -- johnfitz
============
*/
void Cvar_Reset(const std::string &name) {
if (const auto var = Cvar_FindVar(name); !var.has_value())
Con_Printf("variable \"%s\" not found\n", name.c_str());
else
Cvar_SetQuick(var.value(), var.value()->default_string);
}
void Cvar_SetQuick(cvar_t *var, const std::string &value) {
if (var->flags & (CVAR_ROM | CVAR_LOCKED))
return;
if (!(var->flags & CVAR_REGISTERED))
return;
if (!var->string)
var->string = Z_Strdup(value.c_str());
else {
int len;
if (!strcmp(var->string, value.c_str()))
return; // no change
var->flags |= CVAR_CHANGED;
len = value.length();
if (len != Q_strlen(var->string)) {
Z_Free((void *) var->string);
var->string = (char *) Z_Malloc(len + 1);
}
memcpy((char *) var->string, value.c_str(), len + 1);
}
var->value = Q_atof(var->string);
//johnfitz -- save initial value for "reset" command
if (!var->default_string)
var->default_string = Z_Strdup(var->string);
//johnfitz -- during initialization, update default too
else if (!host_initialized) {
// Sys_Printf("changing default of %s: %s -> %s\n",
// var->name, var->default_string, var->string);
Z_Free((void *) var->default_string);
var->default_string = Z_Strdup(var->string);
}
//johnfitz
if (var->callback)
var->callback(var);
}
void Cvar_SetValueQuick(cvar_t *var, const float value) {
char val[32], *ptr = val;
if (value == (float) ((int) value))
q_snprintf(val, sizeof(val), "%i", (int) value);
else {
q_snprintf(val, sizeof(val), "%f", value);
// kill trailing zeroes
while (*ptr)
ptr++;
while (--ptr > val && *ptr == '0' && ptr[-1] != '.')
*ptr = '\0';
}
Cvar_SetQuick(var, val);
}
/*
============
Cvar_Set
============
*/
void Cvar_Set(const std::string &name, const std::string &value) {
auto var = Cvar_FindVar(name);
if (!var.has_value()) {
// there is an error in C code if this happens
Con_Printf("Cvar_Set: variable %s not found\n", name.c_str());
return;
}
Cvar_SetQuick(var.value(), value);
}
/*
============
Cvar_SetValue
============
*/
void Cvar_SetValue(const char *var_name, const float value) {
char val[32], *ptr = val;
if (value == (float) ((int) value))
q_snprintf(val, sizeof(val), "%i", (int) value);
else {
q_snprintf(val, sizeof(val), "%f", value);
// kill trailing zeroes
while (*ptr)
ptr++;
while (--ptr > val && *ptr == '0' && ptr[-1] != '.')
*ptr = '\0';
}
Cvar_Set(var_name, val);
}
/*
============
Cvar_SetROM
============
*/
void Cvar_SetROM(const char *var_name, const char *value) {
if (const auto var = Cvar_FindVar(var_name); var.has_value()) {
var.value()->flags &= ~CVAR_ROM;
Cvar_SetQuick(var.value(), value);
var.value()->flags |= CVAR_ROM;
}
}
/*
============
Cvar_SetValueROM
============
*/
void Cvar_SetValueROM(const char *var_name, const float value) {
if (const auto var = Cvar_FindVar(var_name); var.has_value()) {
var.value()->flags &= ~CVAR_ROM;
Cvar_SetValueQuick(var.value(), value);
var.value()->flags |= CVAR_ROM;
}
}
/*
============
Cvar_RegisterVariable
Adds a freestanding variable to the variable list.
============
*/
void Cvar_RegisterVariable(cvar_t *variable) {
char value[512];
qboolean set_rom;
cvar_t *cursor, *prev; //johnfitz -- sorted list insert
// first check to see if it has already been defined
if (Cvar_FindVar(variable->name)) {
Con_Printf("Can't register variable %s, already defined\n", variable->name);
return;
}
// check for overlap with a command
if (Cmd_Exists(variable->name)) {
Con_Printf("Cvar_RegisterVariable: %s is a command\n", variable->name);
return;
}
CLIENT_VARIABLES.emplace(std::string(variable->name), variable);
//johnfitz
variable->flags |= CVAR_REGISTERED;
// copy the value off, because future sets will Z_Free it
std::strncpy(value, variable->string, sizeof(value));
variable->string = NULL;
variable->default_string = NULL;
if (!(variable->flags & CVAR_CALLBACK))
variable->callback = NULL;
// set it through the function to be consistent
set_rom = (variable->flags & CVAR_ROM);
variable->flags &= ~CVAR_ROM;
Cvar_SetQuick(variable, value);
if (set_rom)
variable->flags |= CVAR_ROM;
}
/*
============
Cvar_SetCallback
Set a callback function to the var
============
*/
void Cvar_SetCallback(cvar_t *var, cvarcallback_t func) {
var->callback = func;
if (func)
var->flags |= CVAR_CALLBACK;
else var->flags &= ~CVAR_CALLBACK;
}
/*
============
Cvar_Command
Handles variable inspection and changing from the console
============
*/
qboolean Cvar_Command() {
// check variables
auto var = Cvar_FindVar(Cmd_Argv(0));
if (!var.has_value())
return false;
// perform a variable print or set
if (Cmd_Argc() == 1) {
Con_Printf("\"%s\" is \"%s\"\n", var.value()->name, var.value()->string);
return true;
}
Cvar_Set(var.value()->name, Cmd_Argv(1));
return true;
}
/*
============
Cvar_WriteVariables
Writes lines containing "set variable value" for all variables
with the archive flag set to true.
============
*/
void Cvar_WriteVariables(FILE *f) {
for (const auto &[name, var] : CLIENT_VARIABLES) {
if (var->flags & CVAR_ARCHIVE)
fprintf(f, "%s \"%s\"\n", name.c_str(), var->string);
}
}
-146
View File
@@ -1,146 +0,0 @@
/*
Copyright (C) 1996-2001 Id Software, Inc.
Copyright (C) 2002-2009 John Fitzgibbons and others
Copyright (C) 2010-2014 QuakeSpasm developers
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __CVAR_H__
#define __CVAR_H__
/*
cvar_t variables are used to hold scalar or string variables that can
be changed or displayed at the console or prog code as well as accessed
directly in C code.
it is sufficient to initialize a cvar_t with just the first two fields,
or you can add a ,true flag for variables that you want saved to the
configuration file when the game is quit:
cvar_t r_draworder = {"r_draworder","1"};
cvar_t scr_screensize = {"screensize","1",true};
Cvars must be registered before use, or they will have a 0 value instead
of the float interpretation of the string.
Generally, all cvar_t declarations should be registered in the apropriate
init function before any console commands are executed:
Cvar_RegisterVariable (&host_framerate);
C code usually just references a cvar in place:
if ( r_draworder.value )
It could optionally ask for the value to be looked up for a string name:
if (Cvar_VariableValue ("r_draworder"))
Interpreted prog code can access cvars with the cvar(name) or
cvar_set (name, value) internal functions:
teamplay = cvar("teamplay");
cvar_set ("registered", "1");
The user can access cvars from the console in two ways:
r_draworder prints the current value
r_draworder 0 sets the current value to 0
Cvars are restricted from having the same names as commands to keep this
interface from being ambiguous.
*/
#define CVAR_NONE 0
#define CVAR_ARCHIVE (1U << 0) // if set, causes it to be saved to config
#define CVAR_NOTIFY (1U << 1) // changes will be broadcasted to all players (q1)
#define CVAR_SERVERINFO (1U << 2) // added to serverinfo will be sent to clients (q1/net_dgrm.c and qwsv)
#define CVAR_USERINFO (1U << 3) // added to userinfo, will be sent to server (qwcl)
#define CVAR_CHANGED (1U << 4)
#define CVAR_ROM (1U << 6)
#define CVAR_LOCKED (1U << 8) // locked temporarily
#define CVAR_REGISTERED (1U << 10) // the var is added to the list of variables
#define CVAR_CALLBACK (1U << 16) // var has a callback
#include <map>
#include <optional>
typedef void (*cvarcallback_t) (struct cvar_s *);
typedef struct cvar_s
{
const char *name;
const char *string;
unsigned int flags;
float value;
const char *default_string; //johnfitz -- remember defaults for reset function
cvarcallback_t callback;
} cvar_t;
void Cvar_RegisterVariable (cvar_t *variable);
// registers a cvar that already has the name, string, and optionally
// the archive elements set.
void Cvar_SetCallback (cvar_t *var, cvarcallback_t func);
// set a callback function to the var
void Cvar_Set(const std::string &name, const std::string &value);
// equivelant to "<name> <variable>" typed at the console
void Cvar_SetValue (const char *var_name, const float value);
// expands value to a string and calls Cvar_Set
void Cvar_SetROM (const char *var_name, const char *value);
void Cvar_SetValueROM (const char *var_name, const float value);
// sets a CVAR_ROM variable from within the engine
void Cvar_SetQuick(cvar_t *var, const std::string &value);
void Cvar_SetValueQuick (cvar_t *var, const float value);
// these two accept a cvar pointer instead of a var name,
// but are otherwise identical to the "non-Quick" versions.
// the cvar MUST be registered.
float Cvar_VariableValue (const char *var_name);
// returns 0 if not defined or non numeric
const char *Cvar_VariableString (const char *var_name);
// returns an empty string if not defined
qboolean Cvar_Command (void);
// called by Cmd_ExecuteString when Cmd_Argv(0) doesn't match a known
// command. Returns true if the command was a variable reference that
// was handled. (print or change)
void Cvar_WriteVariables (FILE *f);
// Writes lines containing "set variable value" for all variables
// with the CVAR_ARCHIVE flag set
std::optional<cvar_t*> Cvar_FindVar (const std::string &desired);
cvar_t *Cvar_FindVarAfter (const char *prev_name, unsigned int with_flags);
void Cvar_LockVar(const std::string &name);
void Cvar_UnlockVar(const std::string &name);
void Cvar_UnlockAll (void);
void Cvar_Init (void);
const char *Cvar_CompleteVariable (const char *partial);
// attempts to match a partial variable name for command line completion
// returns NULL if nothing fits
extern std::map<std::string, cvar_t* > CLIENT_VARIABLES;
#endif /* __CVAR_H__ */
+3 -3
View File
@@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//extern unsigned char d_15to8table[65536]; //johnfitz -- never used //extern unsigned char d_15to8table[65536]; //johnfitz -- never used
cvar_t scr_conalpha = {"scr_conalpha", "0.5", CVAR_ARCHIVE}; //johnfitz convar scr_conalpha = {"scr_conalpha", "0.5", {.archive = true}}; //johnfitz
qpic_t *draw_disc; qpic_t *draw_disc;
qpic_t *draw_backtile; qpic_t *draw_backtile;
@@ -400,7 +400,7 @@ Draw_Init -- johnfitz -- rewritten
*/ */
void Draw_Init (void) void Draw_Init (void)
{ {
Cvar_RegisterVariable (&scr_conalpha); scr_conalpha.inscribe();
// clear scrap and allocate gltextures // clear scrap and allocate gltextures
memset(scrap_allocated, 0, sizeof(scrap_allocated)); memset(scrap_allocated, 0, sizeof(scrap_allocated));
@@ -703,7 +703,7 @@ void GL_SetCanvas (canvastype newcanvas)
glViewport (glx, gly, glwidth, glheight); glViewport (glx, gly, glwidth, glheight);
break; break;
case CANVAS_MENU: case CANVAS_MENU:
s = q_min((float)glwidth / 320.0f, (float)glheight / 200.0f); s = std::min((float)glwidth / 320.0f, (float)glheight / 200.0f);
s = CLAMP (1.0f, scr_menuscale.value, s); s = CLAMP (1.0f, scr_menuscale.value, s);
// ericw -- doubled width to 640 to accommodate long keybindings // ericw -- doubled width to 640 to accommodate long keybindings
glOrtho (0, 640, 200, 0, -99999, 99999); glOrtho (0, 640, 200, 0, -99999, 99999);
+83 -93
View File
@@ -21,6 +21,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
//gl_fog.c -- global and volumetric fog //gl_fog.c -- global and volumetric fog
#include <sstream>
#include "quakedef.hpp" #include "quakedef.hpp"
//============================================================================== //==============================================================================
@@ -52,14 +54,11 @@ Fog_Update
update internal variables update internal variables
============= =============
*/ */
void Fog_Update (float density, float red, float green, float blue, float time) void Fog_Update(float density, float red, float green, float blue, float time) {
{
//save previous settings for fade //save previous settings for fade
if (time > 0) if (time > 0) {
{
//check for a fade in progress //check for a fade in progress
if (fade_done > cl.time) if (fade_done > cl.time) {
{
float f; float f;
f = (fade_done - cl.time) / fade_time; f = (fade_done - cl.time) / fade_time;
@@ -67,9 +66,7 @@ void Fog_Update (float density, float red, float green, float blue, float time)
old_red = f * old_red + (1.0 - f) * fog_red; old_red = f * old_red + (1.0 - f) * fog_red;
old_green = f * old_green + (1.0 - f) * fog_green; old_green = f * old_green + (1.0 - f) * fog_green;
old_blue = f * old_blue + (1.0 - f) * fog_blue; old_blue = f * old_blue + (1.0 - f) * fog_blue;
} } else {
else
{
old_density = fog_density; old_density = fog_density;
old_red = fog_red; old_red = fog_red;
old_green = fog_green; old_green = fog_green;
@@ -92,8 +89,7 @@ Fog_ParseServerMessage
handle an SVC_FOG message from server handle an SVC_FOG message from server
============= =============
*/ */
void Fog_ParseServerMessage (void) void Fog_ParseServerMessage(void) {
{
float density, red, green, blue, time; float density, red, green, blue, time;
density = MSG_ReadByte() / 255.0; density = MSG_ReadByte() / 255.0;
@@ -113,12 +109,10 @@ Fog_FogCommand_f
handle the 'fog' console command handle the 'fog' console command
============= =============
*/ */
void Fog_FogCommand_f (void) void Fog_FogCommand_f(void) {
{
float d, r, g, b, t; float d, r, g, b, t;
switch (Cmd_Argc()) switch (command::argc()) {
{
default: default:
case 1: case 1:
Con_Printf("usage:\n"); Con_Printf("usage:\n");
@@ -132,15 +126,15 @@ void Fog_FogCommand_f (void)
Con_Printf(" \"blue\" is \"%f\"\n", fog_blue); Con_Printf(" \"blue\" is \"%f\"\n", fog_blue);
return; return;
case 2: case 2:
d = Q_atof(Cmd_Argv(1)); d = Q_atof(command::argv(1)->c_str());
t = 0.0f; t = 0.0f;
r = fog_red; r = fog_red;
g = fog_green; g = fog_green;
b = fog_blue; b = fog_blue;
break; break;
case 3: //TEST case 3: //TEST
d = Q_atof(Cmd_Argv(1)); d = Q_atof(command::argv(1)->c_str());
t = Q_atof(Cmd_Argv(2)); t = Q_atof(command::argv(2)->c_str());
r = fog_red; r = fog_red;
g = fog_green; g = fog_green;
b = fog_blue; b = fog_blue;
@@ -148,23 +142,23 @@ void Fog_FogCommand_f (void)
case 4: case 4:
d = fog_density; d = fog_density;
t = 0.0f; t = 0.0f;
r = Q_atof(Cmd_Argv(1)); r = Q_atof(command::argv(1)->c_str());
g = Q_atof(Cmd_Argv(2)); g = Q_atof(command::argv(2)->c_str());
b = Q_atof(Cmd_Argv(3)); b = Q_atof(command::argv(3)->c_str());
break; break;
case 5: case 5:
d = Q_atof(Cmd_Argv(1)); d = Q_atof(command::argv(1)->c_str());
r = Q_atof(Cmd_Argv(2)); r = Q_atof(command::argv(2)->c_str());
g = Q_atof(Cmd_Argv(3)); g = Q_atof(command::argv(3)->c_str());
b = Q_atof(Cmd_Argv(4)); b = Q_atof(command::argv(4)->c_str());
t = 0.0f; t = 0.0f;
break; break;
case 6: //TEST case 6: //TEST
d = Q_atof(Cmd_Argv(1)); d = Q_atof(command::argv(1)->c_str());
r = Q_atof(Cmd_Argv(2)); r = Q_atof(command::argv(2)->c_str());
g = Q_atof(Cmd_Argv(3)); g = Q_atof(command::argv(3)->c_str());
b = Q_atof(Cmd_Argv(4)); b = Q_atof(command::argv(4)->c_str());
t = Q_atof(Cmd_Argv(5)); t = Q_atof(command::argv(5)->c_str());
break; break;
} }
@@ -185,10 +179,9 @@ Fog_ParseWorldspawn
called at map load called at map load
============= =============
*/ */
void Fog_ParseWorldspawn (void) void Fog_ParseWorldspawn() {
{ std::string key{};
char key[128], value[4096]; std::string value{};
const char *data;
//initially no fog //initially no fog
fog_density = DEFAULT_DENSITY; fog_density = DEFAULT_DENSITY;
@@ -204,32 +197,41 @@ void Fog_ParseWorldspawn (void)
fade_time = 0.0; fade_time = 0.0;
fade_done = 0.0; fade_done = 0.0;
data = COM_Parse(cl.worldmodel->entities); std::istringstream ss{cl.worldmodel->entities};
if (!data)
return; // error
if (com_token[0] != '{')
return; // error
while (1)
{
data = COM_Parse(data);
if (!data)
return; // error
if (com_token[0] == '}')
break; // end of worldspawn
if (com_token[0] == '_')
q_strlcpy(key, com_token + 1, sizeof(key));
else
q_strlcpy(key, com_token, sizeof(key));
while (key[0] && key[strlen(key)-1] == ' ') // remove trailing spaces
key[strlen(key)-1] = 0;
data = COM_ParseEx(data, CPE_ALLOWTRUNC);
if (!data)
return; // error
q_strlcpy(value, com_token, sizeof(value));
if (!strcmp("fog", key)) auto token = common::parse_token(ss);
{ if (!token.has_value()) {
sscanf(value, "%f %f %f %f", &fog_density, &fog_red, &fog_green, &fog_blue); return; // error
}
if (token->front() != '{') {
return; // error
}
while (true) {
token = common::parse_token(ss);
if (!token.has_value()) {
return; // error
}
if (token->front() == '}') {
break; // end of worldspawn
}
if (token->front() == '_') {
key = token->substr(1);
} else {
key = token.value();
}
while (!key.empty() && key.back() == ' ') {
key.pop_back();
}
token = common::parse_token(ss);
if (!token.has_value()) {
return; // error
}
value = token.value();
if (key == "fog") {
std::sscanf(value.c_str(), "%f %f %f %f", &fog_density, &fog_red, &fog_green, &fog_blue);
} }
} }
} }
@@ -241,22 +243,18 @@ Fog_GetColor
calculates fog color for this frame, taking into account fade times calculates fog color for this frame, taking into account fade times
============= =============
*/ */
float *Fog_GetColor (void) float *Fog_GetColor(void) {
{
static float c[4]; static float c[4];
float f; float f;
int i; int i;
if (fade_done > cl.time) if (fade_done > cl.time) {
{
f = (fade_done - cl.time) / fade_time; f = (fade_done - cl.time) / fade_time;
c[0] = f * old_red + (1.0 - f) * fog_red; c[0] = f * old_red + (1.0 - f) * fog_red;
c[1] = f * old_green + (1.0 - f) * fog_green; c[1] = f * old_green + (1.0 - f) * fog_green;
c[2] = f * old_blue + (1.0 - f) * fog_blue; c[2] = f * old_blue + (1.0 - f) * fog_blue;
c[3] = 1.0; c[3] = 1.0;
} } else {
else
{
c[0] = fog_red; c[0] = fog_red;
c[1] = fog_green; c[1] = fog_green;
c[2] = fog_blue; c[2] = fog_blue;
@@ -282,16 +280,13 @@ Fog_GetDensity
returns current density of fog returns current density of fog
============= =============
*/ */
float Fog_GetDensity (void) float Fog_GetDensity(void) {
{
float f; float f;
if (fade_done > cl.time) if (fade_done > cl.time) {
{
f = (fade_done - cl.time) / fade_time; f = (fade_done - cl.time) / fade_time;
return f * old_density + (1.0 - f) * fog_density; return f * old_density + (1.0 - f) * fog_density;
} } else
else
return fog_density; return fog_density;
} }
@@ -302,8 +297,7 @@ Fog_SetupFrame
called at the beginning of each frame called at the beginning of each frame
============= =============
*/ */
void Fog_SetupFrame (void) void Fog_SetupFrame(void) {
{
glFogfv(GL_FOG_COLOR, Fog_GetColor()); glFogfv(GL_FOG_COLOR, Fog_GetColor());
glFogf(GL_FOG_DENSITY, Fog_GetDensity() / 64.0); glFogf(GL_FOG_DENSITY, Fog_GetDensity() / 64.0);
} }
@@ -315,8 +309,7 @@ Fog_EnableGFog
called before drawing stuff that should be fogged called before drawing stuff that should be fogged
============= =============
*/ */
void Fog_EnableGFog (void) void Fog_EnableGFog(void) {
{
if (Fog_GetDensity() > 0) if (Fog_GetDensity() > 0)
glEnable(GL_FOG); glEnable(GL_FOG);
} }
@@ -328,8 +321,7 @@ Fog_DisableGFog
called after drawing stuff that should be fogged called after drawing stuff that should be fogged
============= =============
*/ */
void Fog_DisableGFog (void) void Fog_DisableGFog(void) {
{
if (Fog_GetDensity() > 0) if (Fog_GetDensity() > 0)
glDisable(GL_FOG); glDisable(GL_FOG);
} }
@@ -341,8 +333,7 @@ Fog_StartAdditive
called before drawing stuff that is additive blended -- sets fog color to black called before drawing stuff that is additive blended -- sets fog color to black
============= =============
*/ */
void Fog_StartAdditive (void) void Fog_StartAdditive(void) {
{
vec3_t color = {0, 0, 0}; vec3_t color = {0, 0, 0};
if (Fog_GetDensity() > 0) if (Fog_GetDensity() > 0)
@@ -356,8 +347,7 @@ Fog_StopAdditive
called after drawing stuff that is additive blended -- restores fog color called after drawing stuff that is additive blended -- restores fog color
============= =============
*/ */
void Fog_StopAdditive (void) void Fog_StopAdditive(void) {
{
if (Fog_GetDensity() > 0) if (Fog_GetDensity() > 0)
glFogfv(GL_FOG_COLOR, Fog_GetColor()); glFogfv(GL_FOG_COLOR, Fog_GetColor());
} }
@@ -368,10 +358,13 @@ void Fog_StopAdditive (void)
// //
//============================================================================== //==============================================================================
cvar_t r_vfog = {"r_vfog", "1", CVAR_NONE}; convar r_vfog{"r_vfog", "1"};
void Fog_DrawVFog (void){} void Fog_DrawVFog(void) {
void Fog_MarkModels (void){} }
void Fog_MarkModels(void) {
}
//============================================================================== //==============================================================================
// //
@@ -386,8 +379,7 @@ Fog_NewMap
called whenever a map is loaded called whenever a map is loaded
============= =============
*/ */
void Fog_NewMap (void) void Fog_NewMap(void) {
{
Fog_ParseWorldspawn(); //for global fog Fog_ParseWorldspawn(); //for global fog
Fog_MarkModels(); //for volumetric fog Fog_MarkModels(); //for volumetric fog
} }
@@ -399,11 +391,10 @@ Fog_Init
called when quake initializes called when quake initializes
============= =============
*/ */
void Fog_Init (void) void Fog_Init(void) {
{ command::add("fog", Fog_FogCommand_f);
Cmd_AddCommand ("fog",Fog_FogCommand_f);
//Cvar_RegisterVariable (&r_vfog); //r_vfog.inscribe();
//set up global fog //set up global fog
fog_density = DEFAULT_DENSITY; fog_density = DEFAULT_DENSITY;
@@ -421,7 +412,6 @@ Fog_SetupState
ericw -- moved from Fog_Init, state that needs to be setup when a new context is created ericw -- moved from Fog_Init, state that needs to be setup when a new context is created
============= =============
*/ */
void Fog_SetupState (void) void Fog_SetupState(void) {
{
glFogi(GL_FOG_MODE, GL_EXP2); glFogi(GL_FOG_MODE, GL_EXP2);
} }
+16 -16
View File
@@ -36,8 +36,8 @@ static qmodel_t *Mod_LoadModel (qmodel_t *mod, qboolean crash);
static void Mod_Print (void); static void Mod_Print (void);
static cvar_t external_ents = {"external_ents", "1", CVAR_ARCHIVE}; static convar external_ents = {"external_ents", "1", {.archive = true}};
static cvar_t external_vis = {"external_vis", "1", CVAR_ARCHIVE}; static convar external_vis = {"external_vis", "1", {.archive = true}};
static byte *mod_novis; static byte *mod_novis;
static int mod_novis_capacity; static int mod_novis_capacity;
@@ -59,11 +59,11 @@ Mod_Init
*/ */
void Mod_Init (void) void Mod_Init (void)
{ {
Cvar_RegisterVariable (&gl_subdivide_size); gl_subdivide_size.inscribe();
Cvar_RegisterVariable (&external_vis); external_vis.inscribe();
Cvar_RegisterVariable (&external_ents); external_ents.inscribe();
Cmd_AddCommand ("mcache", Mod_Print); command::add ("mcache", Mod_Print);
//johnfitz -- create notexture miptex //johnfitz -- create notexture miptex
r_notexture_mip = (texture_t *) Hunk_AllocName (sizeof(texture_t), "r_notexture_mip"); r_notexture_mip = (texture_t *) Hunk_AllocName (sizeof(texture_t), "r_notexture_mip");
@@ -525,7 +525,7 @@ static void Mod_LoadTextures (lump_t *l)
if (((byte*)(mt+1) + pixels) > (mod_base + l->fileofs + l->filelen)) if (((byte*)(mt+1) + pixels) > (mod_base + l->fileofs + l->filelen))
{ {
Con_DPrintf("Texture %s extends past end of lump\n", mt->name); Con_DPrintf("Texture %s extends past end of lump\n", mt->name);
pixels = q_max(0L, (long)((mod_base + l->fileofs + l->filelen) - (byte*)(mt+1))); pixels = std::max(0L, (long)((mod_base + l->fileofs + l->filelen) - (byte*)(mt+1)));
} }
tx->update_warp = false; //johnfitz tx->update_warp = false; //johnfitz
@@ -2054,21 +2054,21 @@ static void Mod_BoundsFromClipNode (qmodel_t *mod, int hull, int nodenum)
case PLANE_X: case PLANE_X:
if (plane->signbits == 1) if (plane->signbits == 1)
mod->clipmins[0] = q_min(mod->clipmins[0], -plane->dist - mod->hulls[hull].clip_mins[0]); mod->clipmins[0] = std::min(mod->clipmins[0], -plane->dist - mod->hulls[hull].clip_mins[0]);
else else
mod->clipmaxs[0] = q_max(mod->clipmaxs[0], plane->dist - mod->hulls[hull].clip_maxs[0]); mod->clipmaxs[0] = std::max(mod->clipmaxs[0], plane->dist - mod->hulls[hull].clip_maxs[0]);
break; break;
case PLANE_Y: case PLANE_Y:
if (plane->signbits == 2) if (plane->signbits == 2)
mod->clipmins[1] = q_min(mod->clipmins[1], -plane->dist - mod->hulls[hull].clip_mins[1]); mod->clipmins[1] = std::min(mod->clipmins[1], -plane->dist - mod->hulls[hull].clip_mins[1]);
else else
mod->clipmaxs[1] = q_max(mod->clipmaxs[1], plane->dist - mod->hulls[hull].clip_maxs[1]); mod->clipmaxs[1] = std::max(mod->clipmaxs[1], plane->dist - mod->hulls[hull].clip_maxs[1]);
break; break;
case PLANE_Z: case PLANE_Z:
if (plane->signbits == 4) if (plane->signbits == 4)
mod->clipmins[2] = q_min(mod->clipmins[2], -plane->dist - mod->hulls[hull].clip_mins[2]); mod->clipmins[2] = std::min(mod->clipmins[2], -plane->dist - mod->hulls[hull].clip_mins[2]);
else else
mod->clipmaxs[2] = q_max(mod->clipmaxs[2], plane->dist - mod->hulls[hull].clip_maxs[2]); mod->clipmaxs[2] = std::max(mod->clipmaxs[2], plane->dist - mod->hulls[hull].clip_maxs[2]);
break; break;
default: default:
//skip nonaxial planes; don't need them //skip nonaxial planes; don't need them
@@ -2648,8 +2648,8 @@ static void Mod_CalcAliasBounds (aliashdr_t *a)
for (k=0; k<3;k++) for (k=0; k<3;k++)
{ {
loadmodel->mins[k] = q_min(loadmodel->mins[k], v[k]); loadmodel->mins[k] = std::min(loadmodel->mins[k], v[k]);
loadmodel->maxs[k] = q_max(loadmodel->maxs[k], v[k]); loadmodel->maxs[k] = std::max(loadmodel->maxs[k], v[k]);
} }
dist = v[0] * v[0] + v[1] * v[1]; dist = v[0] * v[0] + v[1] * v[1];
if (yawradius < dist) if (yawradius < dist)
@@ -2711,7 +2711,7 @@ Mod_SetExtraFlags -- johnfitz -- set up extra flags that aren't in the mdl
*/ */
void Mod_SetExtraFlags (qmodel_t *mod) void Mod_SetExtraFlags (qmodel_t *mod)
{ {
extern cvar_t r_nolerp_list, r_noshadow_list; extern convar r_nolerp_list, r_noshadow_list;
if (!mod || mod->type != mod_alias) if (!mod || mod->type != mod_alias)
return; return;
+1 -1
View File
@@ -155,7 +155,7 @@ void R_CheckEfrags (void)
Con_DWarning ("%i efrags exceeds standard limit of 640.\n", cl.num_efrags); Con_DWarning ("%i efrags exceeds standard limit of 640.\n", cl.num_efrags);
dev_stats.efrags = cl.num_efrags; dev_stats.efrags = cl.num_efrags;
dev_peakstats.efrags = q_max(cl.num_efrags, dev_peakstats.efrags); dev_peakstats.efrags = std::max(cl.num_efrags, dev_peakstats.efrags);
} }
/* /*
+2 -2
View File
@@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static int r_dlightframecount; static int r_dlightframecount;
extern cvar_t r_flatlightstyles; //johnfitz extern convar r_flatlightstyles; //johnfitz
/* /*
================== ==================
@@ -359,7 +359,7 @@ loc0:
// caused by overlapping surfaces with mixed lighting data. // caused by overlapping surfaces with mixed lighting data.
const float nearby = 8.f; const float nearby = 8.f;
dist += nearby; dist += nearby;
*maxdist = q_min(*maxdist, dist); *maxdist = std::min(*maxdist, dist);
continue; continue;
} }
+121 -182
View File
@@ -55,62 +55,68 @@ mleaf_t *r_viewleaf, *r_oldviewleaf;
int d_lightstylevalue[256]; // 8.8 fraction of base light value int d_lightstylevalue[256]; // 8.8 fraction of base light value
cvar_t r_norefresh = {"r_norefresh","0",CVAR_NONE}; convar r_norefresh{"r_norefresh", "0"};
cvar_t r_drawentities = {"r_drawentities","1",CVAR_NONE}; convar r_drawentities{"r_drawentities", "1"};
cvar_t r_drawviewmodel = {"r_drawviewmodel","1",CVAR_NONE}; convar r_drawviewmodel{"r_drawviewmodel", "1"};
cvar_t r_speeds = {"r_speeds","0",CVAR_NONE}; convar r_speeds{"r_speeds", "0"};
cvar_t r_pos = {"r_pos","0",CVAR_NONE}; convar r_pos{"r_pos", "0"};
cvar_t r_fullbright = {"r_fullbright","0",CVAR_NONE}; convar r_fullbright{"r_fullbright", "0"};
cvar_t r_lightmap = {"r_lightmap","0",CVAR_NONE}; convar r_lightmap{"r_lightmap", "0"};
cvar_t r_shadows = {"r_shadows","0",CVAR_ARCHIVE}; convar r_shadows{"r_shadows", "0", {.archive = true}};
cvar_t r_wateralpha = {"r_wateralpha","1",CVAR_ARCHIVE}; convar r_wateralpha{"r_wateralpha", "1", {.archive = true}};
cvar_t r_litwater = {"r_litwater","1",CVAR_NONE}; convar r_litwater{"r_litwater", "1"};
cvar_t r_dynamic = {"r_dynamic","1",CVAR_ARCHIVE}; convar r_dynamic{"r_dynamic", "1", {.archive = true}};
cvar_t r_novis = {"r_novis","0",CVAR_ARCHIVE}; convar r_novis{"r_novis", "0", {.archive = true}};
cvar_t gl_finish = {"gl_finish","0",CVAR_NONE}; convar gl_finish{"gl_finish", "0"};
cvar_t gl_clear = {"gl_clear","1",CVAR_NONE}; convar gl_clear{"gl_clear", "1"};
cvar_t gl_cull = {"gl_cull","1",CVAR_NONE}; convar gl_cull{"gl_cull", "1"};
cvar_t gl_smoothmodels = {"gl_smoothmodels","1",CVAR_NONE}; convar gl_smoothmodels{"gl_smoothmodels", "1"};
cvar_t gl_affinemodels = {"gl_affinemodels","0",CVAR_NONE}; convar gl_affinemodels{"gl_affinemodels", "0"};
cvar_t gl_polyblend = {"gl_polyblend","1",CVAR_NONE}; convar gl_polyblend{"gl_polyblend", "1"};
cvar_t gl_flashblend = {"gl_flashblend","0",CVAR_ARCHIVE}; convar gl_flashblend{"gl_flashblend", "0", {.archive = true}};
cvar_t gl_playermip = {"gl_playermip","0",CVAR_NONE}; convar gl_playermip{"gl_playermip", "0"};
cvar_t gl_nocolors = {"gl_nocolors","0",CVAR_NONE}; convar gl_nocolors{"gl_nocolors", "0"};
//johnfitz -- new cvars //johnfitz -- new cvars
cvar_t r_stereo = {"r_stereo","0",CVAR_NONE}; convar r_stereo{"r_stereo", "0"};
cvar_t r_stereodepth = {"r_stereodepth","128",CVAR_NONE}; convar r_stereodepth{"r_stereodepth", "128"};
cvar_t r_clearcolor = {"r_clearcolor","2",CVAR_ARCHIVE}; convar r_clearcolor{"r_clearcolor", "2", {.archive = true}};
cvar_t r_drawflat = {"r_drawflat","0",CVAR_NONE}; convar r_drawflat{"r_drawflat", "0"};
cvar_t r_flatlightstyles = {"r_flatlightstyles", "0", CVAR_NONE}; convar r_flatlightstyles{"r_flatlightstyles", "0"};
cvar_t gl_fullbrights = {"gl_fullbrights", "1", CVAR_ARCHIVE}; convar gl_fullbrights{"gl_fullbrights", "1", {.archive = true}};
cvar_t gl_farclip = {"gl_farclip", "65536", CVAR_ARCHIVE}; convar gl_farclip{"gl_farclip", "65536", {.archive = true}};
cvar_t gl_overbright = {"gl_overbright", "1", CVAR_ARCHIVE}; convar gl_overbright{"gl_overbright", "1", {.archive = true}};
cvar_t gl_overbright_models = {"gl_overbright_models", "1", CVAR_ARCHIVE}; convar gl_overbright_models{"gl_overbright_models", "1", {.archive = true}};
cvar_t r_oldskyleaf = {"r_oldskyleaf", "0", CVAR_NONE}; convar r_oldskyleaf{"r_oldskyleaf", "0"};
cvar_t r_drawworld = {"r_drawworld", "1", CVAR_NONE}; convar r_drawworld{"r_drawworld", "1"};
cvar_t r_showtris = {"r_showtris", "0", CVAR_NONE}; convar r_showtris{"r_showtris", "0"};
cvar_t r_showbboxes = {"r_showbboxes", "0", CVAR_NONE}; convar r_showbboxes{"r_showbboxes", "0"};
cvar_t r_lerpmodels = {"r_lerpmodels", "1", CVAR_NONE}; convar r_lerpmodels{"r_lerpmodels", "1"};
cvar_t r_lerpmove = {"r_lerpmove", "1", CVAR_NONE}; convar r_lerpmove{"r_lerpmove", "1"};
cvar_t r_nolerp_list = {"r_nolerp_list", "progs/flame.mdl,progs/flame2.mdl,progs/braztall.mdl,progs/brazshrt.mdl,progs/longtrch.mdl,progs/flame_pyre.mdl,progs/v_saw.mdl,progs/v_xfist.mdl,progs/h2stuff/newfire.mdl", CVAR_NONE}; convar r_nolerp_list{
cvar_t r_noshadow_list = {"r_noshadow_list", "progs/flame2.mdl,progs/flame.mdl,progs/bolt1.mdl,progs/bolt2.mdl,progs/bolt3.mdl,progs/laser.mdl", CVAR_NONE}; "r_nolerp_list",
"progs/flame.mdl,progs/flame2.mdl,progs/braztall.mdl,progs/brazshrt.mdl,progs/longtrch.mdl,progs/flame_pyre.mdl,progs/v_saw.mdl,progs/v_xfist.mdl,progs/h2stuff/newfire.mdl"
};
convar r_noshadow_list{
"r_noshadow_list",
"progs/flame2.mdl,progs/flame.mdl,progs/bolt1.mdl,progs/bolt2.mdl,progs/bolt3.mdl,progs/laser.mdl"
};
extern cvar_t r_vfog; extern convar r_vfog;
//johnfitz //johnfitz
cvar_t gl_zfix = {"gl_zfix", "0", CVAR_NONE}; // QuakeSpasm z-fighting fix convar gl_zfix{"gl_zfix", "0"}; // QuakeSpasm z-fighting fix
cvar_t r_lavaalpha = {"r_lavaalpha","0",CVAR_NONE}; convar r_lavaalpha{"r_lavaalpha", "0"};
cvar_t r_telealpha = {"r_telealpha","0",CVAR_NONE}; convar r_telealpha{"r_telealpha", "0"};
cvar_t r_slimealpha = {"r_slimealpha","0",CVAR_NONE}; convar r_slimealpha{"r_slimealpha", "0"};
float map_wateralpha, map_lavaalpha, map_telealpha, map_slimealpha; float map_wateralpha, map_lavaalpha, map_telealpha, map_slimealpha;
qboolean r_drawflat_cheatsafe, r_fullbright_cheatsafe, r_lightmap_cheatsafe, r_drawworld_cheatsafe; //johnfitz qboolean r_drawflat_cheatsafe, r_fullbright_cheatsafe, r_lightmap_cheatsafe, r_drawworld_cheatsafe; //johnfitz
cvar_t r_scale = {"r_scale", "1", CVAR_ARCHIVE}; convar r_scale{"r_scale", "1", {.archive = true}};
//============================================================================== //==============================================================================
// //
@@ -132,8 +138,7 @@ static GLint textureLoc;
GLSLGamma_DeleteTexture GLSLGamma_DeleteTexture
============= =============
*/ */
void GLSLGamma_DeleteTexture (void) void GLSLGamma_DeleteTexture(void) {
{
glDeleteTextures(1, &r_gamma_texture); glDeleteTextures(1, &r_gamma_texture);
r_gamma_texture = 0; r_gamma_texture = 0;
r_gamma_program = 0; // deleted in R_DeleteShaders r_gamma_program = 0; // deleted in R_DeleteShaders
@@ -144,9 +149,8 @@ void GLSLGamma_DeleteTexture (void)
GLSLGamma_CreateShaders GLSLGamma_CreateShaders
============= =============
*/ */
static void GLSLGamma_CreateShaders (void) static void GLSLGamma_CreateShaders(void) {
{ const GLchar *vertSource =
const GLchar *vertSource = \
"#version 110\n" "#version 110\n"
"\n" "\n"
"void main(void) {\n" "void main(void) {\n"
@@ -154,7 +158,7 @@ static void GLSLGamma_CreateShaders (void)
" gl_TexCoord[0] = gl_MultiTexCoord0;\n" " gl_TexCoord[0] = gl_MultiTexCoord0;\n"
"}\n"; "}\n";
const GLchar *fragSource = \ const GLchar *fragSource =
"#version 110\n" "#version 110\n"
"\n" "\n"
"uniform sampler2D GammaTexture;\n" "uniform sampler2D GammaTexture;\n"
@@ -183,8 +187,7 @@ static void GLSLGamma_CreateShaders (void)
GLSLGamma_GammaCorrect GLSLGamma_GammaCorrect
============= =============
*/ */
void GLSLGamma_GammaCorrect (void) void GLSLGamma_GammaCorrect(void) {
{
float smax, tmax; float smax, tmax;
if (!gl_glsl_gamma_able) if (!gl_glsl_gamma_able)
@@ -194,31 +197,28 @@ void GLSLGamma_GammaCorrect (void)
return; return;
// create render-to-texture texture if needed // create render-to-texture texture if needed
if (!r_gamma_texture) if (!r_gamma_texture) {
{
glGenTextures(1, &r_gamma_texture); glGenTextures(1, &r_gamma_texture);
glBindTexture(GL_TEXTURE_2D, r_gamma_texture); glBindTexture(GL_TEXTURE_2D, r_gamma_texture);
r_gamma_texture_width = glwidth; r_gamma_texture_width = glwidth;
r_gamma_texture_height = glheight; r_gamma_texture_height = glheight;
if (!gl_texture_NPOT) if (!gl_texture_NPOT) {
{
r_gamma_texture_width = TexMgr_Pad(r_gamma_texture_width); r_gamma_texture_width = TexMgr_Pad(r_gamma_texture_width);
r_gamma_texture_height = TexMgr_Pad(r_gamma_texture_height); r_gamma_texture_height = TexMgr_Pad(r_gamma_texture_height);
} }
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, r_gamma_texture_width, r_gamma_texture_height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, r_gamma_texture_width, r_gamma_texture_height, 0, GL_BGRA,
GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
} }
// create shader if needed // create shader if needed
if (!r_gamma_program) if (!r_gamma_program) {
{
GLSLGamma_CreateShaders(); GLSLGamma_CreateShaders();
if (!r_gamma_program) if (!r_gamma_program) {
{
Sys_Error("GLSLGamma_CreateShaders failed"); Sys_Error("GLSLGamma_CreateShaders failed");
} }
} }
@@ -231,7 +231,7 @@ void GLSLGamma_GammaCorrect (void)
// draw the texture back to the framebuffer with a fragment shader // draw the texture back to the framebuffer with a fragment shader
GL_UseProgramFunc(r_gamma_program); GL_UseProgramFunc(r_gamma_program);
GL_Uniform1fFunc(gammaLoc, vid_gamma.value); GL_Uniform1fFunc(gammaLoc, vid_gamma.value);
GL_Uniform1fFunc (contrastLoc, q_min(2.0f, q_max(1.0f, vid_contrast.value))); GL_Uniform1fFunc(contrastLoc, std::min(2.0f, std::max(1.0f, vid_contrast.value)));
GL_Uniform1iFunc(textureLoc, 0); // use texture unit 0 GL_Uniform1iFunc(textureLoc, 0); // use texture unit 0
glDisable(GL_ALPHA_TEST); glDisable(GL_ALPHA_TEST);
@@ -266,15 +266,13 @@ R_CullBox -- johnfitz -- replaced with new function from lordhavoc
Returns true if the box is completely outside the frustum Returns true if the box is completely outside the frustum
================= =================
*/ */
qboolean R_CullBox (vec3_t emins, vec3_t emaxs) qboolean R_CullBox(vec3_t emins, vec3_t emaxs) {
{
int i; int i;
mplane_t *p; mplane_t *p;
byte signbits; byte signbits;
float vec[3]; float vec[3];
for (i = 0;i < 4;i++) for (i = 0; i < 4; i++) {
{
p = frustum + i; p = frustum + i;
signbits = p->signbits; signbits = p->signbits;
vec[0] = ((signbits & 1) ? emins : emaxs)[0]; vec[0] = ((signbits & 1) ? emins : emaxs)[0];
@@ -291,8 +289,7 @@ qboolean R_CullBox (vec3_t emins, vec3_t emaxs)
R_CullModelForEntity -- johnfitz -- uses correct bounds based on rotation R_CullModelForEntity -- johnfitz -- uses correct bounds based on rotation
=============== ===============
*/ */
qboolean R_CullModelForEntity (entity_t *e) qboolean R_CullModelForEntity(entity_t *e) {
{
vec3_t mins, maxs; vec3_t mins, maxs;
vec_t scalefactor, *minbounds, *maxbounds; vec_t scalefactor, *minbounds, *maxbounds;
@@ -300,26 +297,21 @@ qboolean R_CullModelForEntity (entity_t *e)
{ {
minbounds = e->model->rmins; minbounds = e->model->rmins;
maxbounds = e->model->rmaxs; maxbounds = e->model->rmaxs;
} } else if (e->angles[1]) //yaw
else if (e->angles[1]) //yaw
{ {
minbounds = e->model->ymins; minbounds = e->model->ymins;
maxbounds = e->model->ymaxs; maxbounds = e->model->ymaxs;
} } else //no rotation
else //no rotation
{ {
minbounds = e->model->mins; minbounds = e->model->mins;
maxbounds = e->model->maxs; maxbounds = e->model->maxs;
} }
scalefactor = ENTSCALE_DECODE(e->scale); scalefactor = ENTSCALE_DECODE(e->scale);
if (scalefactor != 1.0f) if (scalefactor != 1.0f) {
{
VectorMA(e->origin, scalefactor, minbounds, mins); VectorMA(e->origin, scalefactor, minbounds, mins);
VectorMA(e->origin, scalefactor, maxbounds, maxs); VectorMA(e->origin, scalefactor, maxbounds, maxs);
} } else {
else
{
VectorAdd(e->origin, minbounds, mins); VectorAdd(e->origin, minbounds, mins);
VectorAdd(e->origin, maxbounds, maxs); VectorAdd(e->origin, maxbounds, maxs);
} }
@@ -332,8 +324,7 @@ qboolean R_CullModelForEntity (entity_t *e)
R_RotateForEntity -- johnfitz -- modified to take origin and angles instead of pointer to entity R_RotateForEntity -- johnfitz -- modified to take origin and angles instead of pointer to entity
=============== ===============
*/ */
void R_RotateForEntity (vec3_t origin, vec3_t angles, unsigned char scale) void R_RotateForEntity(vec3_t origin, vec3_t angles, unsigned char scale) {
{
float scalefactor = ENTSCALE_DECODE(scale); float scalefactor = ENTSCALE_DECODE(scale);
glTranslatef(origin[0], origin[1], origin[2]); glTranslatef(origin[0], origin[1], origin[2]);
glRotatef(angles[1], 0, 0, 1); glRotatef(angles[1], 0, 0, 1);
@@ -350,22 +341,16 @@ GL_PolygonOffset -- johnfitz
negative offset moves polygon closer to camera negative offset moves polygon closer to camera
============= =============
*/ */
void GL_PolygonOffset (int offset) void GL_PolygonOffset(int offset) {
{ if (offset > 0) {
if (offset > 0)
{
glEnable(GL_POLYGON_OFFSET_FILL); glEnable(GL_POLYGON_OFFSET_FILL);
glEnable(GL_POLYGON_OFFSET_LINE); glEnable(GL_POLYGON_OFFSET_LINE);
glPolygonOffset(1, offset); glPolygonOffset(1, offset);
} } else if (offset < 0) {
else if (offset < 0)
{
glEnable(GL_POLYGON_OFFSET_FILL); glEnable(GL_POLYGON_OFFSET_FILL);
glEnable(GL_POLYGON_OFFSET_LINE); glEnable(GL_POLYGON_OFFSET_LINE);
glPolygonOffset(-1, offset); glPolygonOffset(-1, offset);
} } else {
else
{
glDisable(GL_POLYGON_OFFSET_FILL); glDisable(GL_POLYGON_OFFSET_FILL);
glDisable(GL_POLYGON_OFFSET_LINE); glDisable(GL_POLYGON_OFFSET_LINE);
} }
@@ -377,15 +362,13 @@ void GL_PolygonOffset (int offset)
// //
//============================================================================== //==============================================================================
int SignbitsForPlane (mplane_t *out) int SignbitsForPlane(mplane_t *out) {
{
int bits, j; int bits, j;
// for fast box on planeside test // for fast box on planeside test
bits = 0; bits = 0;
for (j=0 ; j<3 ; j++) for (j = 0; j < 3; j++) {
{
if (out->normal[j] < 0) if (out->normal[j] < 0)
bits |= 1 << j; bits |= 1 << j;
} }
@@ -402,8 +385,7 @@ assumes side and forward are perpendicular, and normalized
to turn away from side, use a negative angle to turn away from side, use a negative angle
=============== ===============
*/ */
void TurnVector (vec3_t out, const vec3_t forward, const vec3_t side, float angle) void TurnVector(vec3_t out, const vec3_t forward, const vec3_t side, float angle) {
{
float scale_forward, scale_side; float scale_forward, scale_side;
scale_forward = cos(DEG2RAD(angle)); scale_forward = cos(DEG2RAD(angle));
@@ -419,8 +401,7 @@ void TurnVector (vec3_t out, const vec3_t forward, const vec3_t side, float angl
R_SetFrustum -- johnfitz -- rewritten R_SetFrustum -- johnfitz -- rewritten
=============== ===============
*/ */
void R_SetFrustum (float fovx, float fovy) void R_SetFrustum(float fovx, float fovy) {
{
int i; int i;
if (r_stereo.value) if (r_stereo.value)
@@ -431,8 +412,7 @@ void R_SetFrustum (float fovx, float fovy)
TurnVector(frustum[2].normal, vpn, vup, 90 - fovy / 2); //bottom plane TurnVector(frustum[2].normal, vpn, vup, 90 - fovy / 2); //bottom plane
TurnVector(frustum[3].normal, vpn, vup, fovy / 2 - 90); //top plane TurnVector(frustum[3].normal, vpn, vup, fovy / 2 - 90); //top plane
for (i=0 ; i<4 ; i++) for (i = 0; i < 4; i++) {
{
frustum[i].type = PLANE_ANYZ; frustum[i].type = PLANE_ANYZ;
frustum[i].dist = DotProduct(r_origin, frustum[i].normal); //FIXME: shouldn't this always be zero? frustum[i].dist = DotProduct(r_origin, frustum[i].normal); //FIXME: shouldn't this always be zero?
frustum[i].signbits = SignbitsForPlane(&frustum[i]); frustum[i].signbits = SignbitsForPlane(&frustum[i]);
@@ -446,8 +426,7 @@ GL_SetFrustum -- johnfitz -- written to replace MYgluPerspective
*/ */
#define NEARCLIP 4 #define NEARCLIP 4
float frustum_skew = 0.0; //used by r_stereo float frustum_skew = 0.0; //used by r_stereo
void GL_SetFrustum(float fovx, float fovy) void GL_SetFrustum(float fovx, float fovy) {
{
float xmax, ymax; float xmax, ymax;
xmax = NEARCLIP * tan(fovx * M_PI / 360.0); xmax = NEARCLIP * tan(fovx * M_PI / 360.0);
ymax = NEARCLIP * tan(fovy * M_PI / 360.0); ymax = NEARCLIP * tan(fovy * M_PI / 360.0);
@@ -459,8 +438,7 @@ void GL_SetFrustum(float fovx, float fovy)
R_SetupGL R_SetupGL
============= =============
*/ */
void R_SetupGL (void) void R_SetupGL(void) {
{
int scale; int scale;
//johnfitz -- rewrote this section //johnfitz -- rewrote this section
@@ -505,8 +483,7 @@ void R_SetupGL (void)
R_Clear -- johnfitz -- rewritten and gutted R_Clear -- johnfitz -- rewritten and gutted
============= =============
*/ */
void R_Clear (void) void R_Clear(void) {
{
unsigned int clearbits; unsigned int clearbits;
clearbits = GL_DEPTH_BUFFER_BIT; clearbits = GL_DEPTH_BUFFER_BIT;
@@ -523,8 +500,7 @@ void R_Clear (void)
R_SetupScene -- johnfitz -- this is the stuff that needs to be done once per eye in stereo mode R_SetupScene -- johnfitz -- this is the stuff that needs to be done once per eye in stereo mode
=============== ===============
*/ */
void R_SetupScene (void) void R_SetupScene(void) {
{
R_SetupGL(); R_SetupGL();
} }
@@ -533,8 +509,7 @@ void R_SetupScene (void)
R_SetupView -- johnfitz -- this is the stuff that needs to be done once per frame, even in stereo mode R_SetupView -- johnfitz -- this is the stuff that needs to be done once per frame, even in stereo mode
=============== ===============
*/ */
void R_SetupView (void) void R_SetupView(void) {
{
// Need to do those early because we now update dynamic light maps during R_MarkSurfaces // Need to do those early because we now update dynamic light maps during R_MarkSurfaces
R_PushDlights(); R_PushDlights();
R_AnimateLight(); R_AnimateLight();
@@ -556,11 +531,9 @@ void R_SetupView (void)
//johnfitz -- calculate r_fovx and r_fovy here //johnfitz -- calculate r_fovx and r_fovy here
r_fovx = r_refdef.fov_x; r_fovx = r_refdef.fov_x;
r_fovy = r_refdef.fov_y; r_fovy = r_refdef.fov_y;
if (r_waterwarp.value) if (r_waterwarp.value) {
{
int contents = Mod_PointInLeaf(r_origin, cl.worldmodel)->contents; int contents = Mod_PointInLeaf(r_origin, cl.worldmodel)->contents;
if (contents == CONTENTS_WATER || contents == CONTENTS_SLIME || contents == CONTENTS_LAVA) if (contents == CONTENTS_WATER || contents == CONTENTS_SLIME || contents == CONTENTS_LAVA) {
{
//variance is a percentage of width, where width = 2 * tan(fov / 2) otherwise the effect is too dramatic at high FOV and too subtle at low FOV. what a mess! //variance is a percentage of width, where width = 2 * tan(fov / 2) otherwise the effect is too dramatic at high FOV and too subtle at low FOV. what a mess!
r_fovx = atan(tan(DEG2RAD(r_refdef.fov_x) / 2) * (0.97 + sin(cl.time * 1.5) * 0.03)) * 2 / M_PI_DIV_180; r_fovx = atan(tan(DEG2RAD(r_refdef.fov_x) / 2) * (0.97 + sin(cl.time * 1.5) * 0.03)) * 2 / M_PI_DIV_180;
r_fovy = atan(tan(DEG2RAD(r_refdef.fov_y) / 2) * (1.03 - sin(cl.time * 1.5) * 0.03)) * 2 / M_PI_DIV_180; r_fovy = atan(tan(DEG2RAD(r_refdef.fov_y) / 2) * (1.03 - sin(cl.time * 1.5) * 0.03)) * 2 / M_PI_DIV_180;
@@ -579,8 +552,7 @@ void R_SetupView (void)
//johnfitz -- cheat-protect some draw modes //johnfitz -- cheat-protect some draw modes
r_drawflat_cheatsafe = r_fullbright_cheatsafe = r_lightmap_cheatsafe = false; r_drawflat_cheatsafe = r_fullbright_cheatsafe = r_lightmap_cheatsafe = false;
r_drawworld_cheatsafe = true; r_drawworld_cheatsafe = true;
if (cl.maxclients == 1) if (cl.maxclients == 1) {
{
if (!r_drawworld.value) r_drawworld_cheatsafe = false; if (!r_drawworld.value) r_drawworld_cheatsafe = false;
if (r_drawflat.value) r_drawflat_cheatsafe = true; if (r_drawflat.value) r_drawflat_cheatsafe = true;
@@ -609,8 +581,7 @@ void R_DrawEntitiesOnList (qboolean alphapass) //johnfitz -- added parameter
return; return;
//johnfitz -- sprites are not a special case //johnfitz -- sprites are not a special case
for (i=0 ; i<cl_numvisedicts ; i++) for (i = 0; i < cl_numvisedicts; i++) {
{
currententity = cl_visedicts[i]; currententity = cl_visedicts[i];
//johnfitz -- if alphapass is true, draw only alpha entites this time //johnfitz -- if alphapass is true, draw only alpha entites this time
@@ -624,8 +595,7 @@ void R_DrawEntitiesOnList (qboolean alphapass) //johnfitz -- added parameter
currententity->angles[0] *= 0.3; currententity->angles[0] *= 0.3;
//johnfitz //johnfitz
switch (currententity->model->type) switch (currententity->model->type) {
{
case mod_alias: case mod_alias:
R_DrawAliasModel(currententity); R_DrawAliasModel(currententity);
break; break;
@@ -644,8 +614,7 @@ void R_DrawEntitiesOnList (qboolean alphapass) //johnfitz -- added parameter
R_DrawViewModel -- johnfitz -- gutted R_DrawViewModel -- johnfitz -- gutted
============= =============
*/ */
void R_DrawViewModel (void) void R_DrawViewModel(void) {
{
if (!r_drawviewmodel.value || !r_drawentities.value || chase_active.value) if (!r_drawviewmodel.value || !r_drawentities.value || chase_active.value)
return; return;
@@ -672,8 +641,7 @@ void R_DrawViewModel (void)
R_EmitWirePoint -- johnfitz -- draws a wireframe cross shape for point entities R_EmitWirePoint -- johnfitz -- draws a wireframe cross shape for point entities
================ ================
*/ */
void R_EmitWirePoint (vec3_t origin) void R_EmitWirePoint(vec3_t origin) {
{
const int size = 8; const int size = 8;
glBegin(GL_LINES); glBegin(GL_LINES);
@@ -691,8 +659,7 @@ void R_EmitWirePoint (vec3_t origin)
R_EmitWireBox -- johnfitz -- draws one axis aligned bounding box R_EmitWireBox -- johnfitz -- draws one axis aligned bounding box
================ ================
*/ */
void R_EmitWireBox (vec3_t mins, vec3_t maxs) void R_EmitWireBox(vec3_t mins, vec3_t maxs) {
{
glBegin(GL_QUAD_STRIP); glBegin(GL_QUAD_STRIP);
glVertex3f(mins[0], mins[1], mins[2]); glVertex3f(mins[0], mins[1], mins[2]);
glVertex3f(mins[0], mins[1], maxs[2]); glVertex3f(mins[0], mins[1], maxs[2]);
@@ -714,8 +681,7 @@ R_ShowBoundingBoxes -- johnfitz
draw bounding boxes -- the server-side boxes, not the renderer cullboxes draw bounding boxes -- the server-side boxes, not the renderer cullboxes
================ ================
*/ */
void R_ShowBoundingBoxes (void) void R_ShowBoundingBoxes(void) {
{
extern edict_t *sv_player; extern edict_t *sv_player;
vec3_t mins, maxs; vec3_t mins, maxs;
edict_t *ed; edict_t *ed;
@@ -731,8 +697,7 @@ void R_ShowBoundingBoxes (void)
glDisable(GL_CULL_FACE); glDisable(GL_CULL_FACE);
glColor3f(1, 1, 1); glColor3f(1, 1, 1);
for (i=1, ed=NEXT_EDICT(sv.edicts) ; i<sv.num_edicts ; i++, ed=NEXT_EDICT(ed)) for (i = 1, ed = NEXT_EDICT(sv.edicts); i < sv.num_edicts; i++, ed = NEXT_EDICT(ed)) {
{
if (ed == sv_player || ed->free) if (ed == sv_player || ed->free)
continue; //don't draw player's own bbox or freed edicts continue; //don't draw player's own bbox or freed edicts
@@ -740,13 +705,10 @@ void R_ShowBoundingBoxes (void)
// if (!SV_VisibleToClient (sv_player, ed, sv.worldmodel)) // if (!SV_VisibleToClient (sv_player, ed, sv.worldmodel))
// continue; //don't draw if not in pvs // continue; //don't draw if not in pvs
if (ed->v.mins[0] == ed->v.maxs[0] && ed->v.mins[1] == ed->v.maxs[1] && ed->v.mins[2] == ed->v.maxs[2]) if (ed->v.mins[0] == ed->v.maxs[0] && ed->v.mins[1] == ed->v.maxs[1] && ed->v.mins[2] == ed->v.maxs[2]) {
{
//point entity //point entity
R_EmitWirePoint(ed->v.origin); R_EmitWirePoint(ed->v.origin);
} } else {
else
{
//box entity //box entity
VectorAdd(ed->v.mins, ed->v.origin, mins); VectorAdd(ed->v.mins, ed->v.origin, mins);
VectorAdd(ed->v.maxs, ed->v.origin, maxs); VectorAdd(ed->v.maxs, ed->v.origin, maxs);
@@ -769,9 +731,8 @@ void R_ShowBoundingBoxes (void)
R_ShowTris -- johnfitz R_ShowTris -- johnfitz
================ ================
*/ */
void R_ShowTris (void) void R_ShowTris(void) {
{ extern convar r_particles;
extern cvar_t r_particles;
int i; int i;
if (r_showtris.value < 1 || r_showtris.value > 2 || cl.maxclients > 1) if (r_showtris.value < 1 || r_showtris.value > 2 || cl.maxclients > 1)
@@ -786,22 +747,18 @@ void R_ShowTris (void)
// glEnable (GL_BLEND); // glEnable (GL_BLEND);
// glBlendFunc (GL_ONE, GL_ONE); // glBlendFunc (GL_ONE, GL_ONE);
if (r_drawworld.value) if (r_drawworld.value) {
{
R_DrawWorld_ShowTris(); R_DrawWorld_ShowTris();
} }
if (r_drawentities.value) if (r_drawentities.value) {
{ for (i = 0; i < cl_numvisedicts; i++) {
for (i=0 ; i<cl_numvisedicts ; i++)
{
currententity = cl_visedicts[i]; currententity = cl_visedicts[i];
if (currententity == &cl_entities[cl.viewentity]) // chasecam if (currententity == &cl_entities[cl.viewentity]) // chasecam
currententity->angles[0] *= 0.3; currententity->angles[0] *= 0.3;
switch (currententity->model->type) switch (currententity->model->type) {
{
case mod_brush: case mod_brush:
R_DrawBrushModel_ShowTris(currententity); R_DrawBrushModel_ShowTris(currententity);
break; break;
@@ -823,16 +780,14 @@ void R_ShowTris (void)
&& cl.stats[STAT_HEALTH] > 0 && cl.stats[STAT_HEALTH] > 0
&& !(cl.items & IT_INVISIBILITY) && !(cl.items & IT_INVISIBILITY)
&& currententity->model && currententity->model
&& currententity->model->type == mod_alias) && currententity->model->type == mod_alias) {
{
glDepthRange(0, 0.3); glDepthRange(0, 0.3);
R_DrawAliasModel_ShowTris(currententity); R_DrawAliasModel_ShowTris(currententity);
glDepthRange(0, 1); glDepthRange(0, 1);
} }
} }
if (r_particles.value) if (r_particles.value) {
{
R_DrawParticles_ShowTris(); R_DrawParticles_ShowTris();
} }
@@ -853,24 +808,21 @@ void R_ShowTris (void)
R_DrawShadows R_DrawShadows
================ ================
*/ */
void R_DrawShadows (void) void R_DrawShadows(void) {
{
int i; int i;
if (!r_shadows.value || !r_drawentities.value || r_drawflat_cheatsafe || r_lightmap_cheatsafe) if (!r_shadows.value || !r_drawentities.value || r_drawflat_cheatsafe || r_lightmap_cheatsafe)
return; return;
// Use stencil buffer to prevent self-intersecting shadows, from Baker (MarkV) // Use stencil buffer to prevent self-intersecting shadows, from Baker (MarkV)
if (gl_stencilbits) if (gl_stencilbits) {
{
glClear(GL_STENCIL_BUFFER_BIT); glClear(GL_STENCIL_BUFFER_BIT);
glStencilFunc(GL_EQUAL, 0, ~0); glStencilFunc(GL_EQUAL, 0, ~0);
glStencilOp(GL_KEEP, GL_KEEP, GL_INCR); glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
glEnable(GL_STENCIL_TEST); glEnable(GL_STENCIL_TEST);
} }
for (i=0 ; i<cl_numvisedicts ; i++) for (i = 0; i < cl_numvisedicts; i++) {
{
currententity = cl_visedicts[i]; currententity = cl_visedicts[i];
if (currententity->model->type != mod_alias) if (currententity->model->type != mod_alias)
@@ -882,8 +834,7 @@ void R_DrawShadows (void)
GL_DrawAliasShadow(currententity); GL_DrawAliasShadow(currententity);
} }
if (gl_stencilbits) if (gl_stencilbits) {
{
glDisable(GL_STENCIL_TEST); glDisable(GL_STENCIL_TEST);
} }
} }
@@ -893,8 +844,7 @@ void R_DrawShadows (void)
R_RenderScene R_RenderScene
================ ================
*/ */
void R_RenderScene (void) void R_RenderScene(void) {
{
R_SetupScene(); //johnfitz -- this does everything that should be done once per call to RenderScene R_SetupScene(); //johnfitz -- this does everything that should be done once per call to RenderScene
Fog_EnableGFog(); //johnfitz Fog_EnableGFog(); //johnfitz
@@ -934,8 +884,7 @@ static int r_scaleview_texture_width, r_scaleview_texture_height;
R_ScaleView_DeleteTexture R_ScaleView_DeleteTexture
============= =============
*/ */
void R_ScaleView_DeleteTexture (void) void R_ScaleView_DeleteTexture(void) {
{
glDeleteTextures(1, &r_scaleview_texture); glDeleteTextures(1, &r_scaleview_texture);
r_scaleview_texture = 0; r_scaleview_texture = 0;
} }
@@ -950,8 +899,7 @@ r_refdef.vrect. This is for emulating a low-resolution pixellated look,
or possibly as a perforance boost on slow graphics cards. or possibly as a perforance boost on slow graphics cards.
================ ================
*/ */
void R_ScaleView (void) void R_ScaleView(void) {
{
float smax, tmax; float smax, tmax;
int scale; int scale;
int srcx, srcy, srcw, srch; int srcx, srcy, srcw, srch;
@@ -970,8 +918,7 @@ void R_ScaleView (void)
GL_DisableMultitexture(); GL_DisableMultitexture();
// create (if needed) and bind the render-to-texture texture // create (if needed) and bind the render-to-texture texture
if (!r_scaleview_texture) if (!r_scaleview_texture) {
{
glGenTextures(1, &r_scaleview_texture); glGenTextures(1, &r_scaleview_texture);
r_scaleview_texture_width = 0; r_scaleview_texture_width = 0;
@@ -981,18 +928,17 @@ void R_ScaleView (void)
// resize render-to-texture texture if needed // resize render-to-texture texture if needed
if (r_scaleview_texture_width < srcw if (r_scaleview_texture_width < srcw
|| r_scaleview_texture_height < srch) || r_scaleview_texture_height < srch) {
{
r_scaleview_texture_width = srcw; r_scaleview_texture_width = srcw;
r_scaleview_texture_height = srch; r_scaleview_texture_height = srch;
if (!gl_texture_NPOT) if (!gl_texture_NPOT) {
{
r_scaleview_texture_width = TexMgr_Pad(r_scaleview_texture_width); r_scaleview_texture_width = TexMgr_Pad(r_scaleview_texture_width);
r_scaleview_texture_height = TexMgr_Pad(r_scaleview_texture_height); r_scaleview_texture_height = TexMgr_Pad(r_scaleview_texture_height);
} }
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, r_scaleview_texture_width, r_scaleview_texture_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, r_scaleview_texture_width, r_scaleview_texture_height, 0, GL_RGBA,
GL_UNSIGNED_BYTE, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
} }
@@ -1038,8 +984,7 @@ void R_ScaleView (void)
R_RenderView R_RenderView
================ ================
*/ */
void R_RenderView (void) void R_RenderView(void) {
{
double time1, time2; double time1, time2;
if (r_norefresh.value) if (r_norefresh.value)
@@ -1049,23 +994,20 @@ void R_RenderView (void)
Sys_Error("R_RenderView: NULL worldmodel"); Sys_Error("R_RenderView: NULL worldmodel");
time1 = 0; /* avoid compiler warning */ time1 = 0; /* avoid compiler warning */
if (r_speeds.value) if (r_speeds.value) {
{
glFinish(); glFinish();
time1 = Sys_DoubleTime(); time1 = Sys_DoubleTime();
//johnfitz -- rendering statistics //johnfitz -- rendering statistics
rs_brushpolys = rs_aliaspolys = rs_skypolys = rs_brushpolys = rs_aliaspolys = rs_skypolys =
rs_dynamiclightmaps = rs_aliaspasses = rs_skypasses = rs_brushpasses = 0; rs_dynamiclightmaps = rs_aliaspasses = rs_skypasses = rs_brushpasses = 0;
} } else if (gl_finish.value)
else if (gl_finish.value)
glFinish(); glFinish();
R_SetupView(); //johnfitz -- this does everything that should be done once per frame R_SetupView(); //johnfitz -- this does everything that should be done once per frame
//johnfitz -- stereo rendering -- full of hacky goodness //johnfitz -- stereo rendering -- full of hacky goodness
if (r_stereo.value) if (r_stereo.value) {
{
float eyesep = CLAMP(-8.0f, r_stereo.value, 8.0f); float eyesep = CLAMP(-8.0f, r_stereo.value, 8.0f);
float fdepth = CLAMP(32.0f, r_stereodepth.value, 1024.0f); float fdepth = CLAMP(32.0f, r_stereodepth.value, 1024.0f);
@@ -1092,9 +1034,7 @@ void R_RenderView (void)
glColorMask(1, 1, 1, 1); glColorMask(1, 1, 1, 1);
VectorMA(r_refdef.vieworg, -0.5f * eyesep, vright, r_refdef.vieworg); VectorMA(r_refdef.vieworg, -0.5f * eyesep, vright, r_refdef.vieworg);
frustum_skew = 0.0f; frustum_skew = 0.0f;
} } else {
else
{
R_RenderScene(); R_RenderScene();
} }
//johnfitz //johnfitz
@@ -1130,4 +1070,3 @@ void R_RenderView (void)
rs_dynamiclightmaps); rs_dynamiclightmaps);
//johnfitz //johnfitz
} }
+166 -190
View File
@@ -22,35 +22,37 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
// r_misc.c // r_misc.c
#include <sstream>
#include "quakedef.hpp" #include "quakedef.hpp"
//johnfitz -- new cvars //johnfitz -- new cvars
extern cvar_t r_stereo; extern convar r_stereo;
extern cvar_t r_stereodepth; extern convar r_stereodepth;
extern cvar_t r_clearcolor; extern convar r_clearcolor;
extern cvar_t r_drawflat; extern convar r_drawflat;
extern cvar_t r_flatlightstyles; extern convar r_flatlightstyles;
extern cvar_t gl_fullbrights; extern convar gl_fullbrights;
extern cvar_t gl_farclip; extern convar gl_farclip;
extern cvar_t gl_overbright; extern convar gl_overbright;
extern cvar_t gl_overbright_models; extern convar gl_overbright_models;
extern cvar_t r_waterquality; extern convar r_waterquality;
extern cvar_t r_oldwater; extern convar r_oldwater;
extern cvar_t r_waterwarp; extern convar r_waterwarp;
extern cvar_t r_oldskyleaf; extern convar r_oldskyleaf;
extern cvar_t r_drawworld; extern convar r_drawworld;
extern cvar_t r_showtris; extern convar r_showtris;
extern cvar_t r_showbboxes; extern convar r_showbboxes;
extern cvar_t r_lerpmodels; extern convar r_lerpmodels;
extern cvar_t r_lerpmove; extern convar r_lerpmove;
extern cvar_t r_nolerp_list; extern convar r_nolerp_list;
extern cvar_t r_noshadow_list; extern convar r_noshadow_list;
//johnfitz //johnfitz
extern cvar_t gl_zfix; // QuakeSpasm z-fighting fix extern convar gl_zfix; // QuakeSpasm z-fighting fix
extern gltexture_t *playertextures[MAX_SCOREBOARD]; //johnfitz extern gltexture_t *playertextures[MAX_SCOREBOARD]; //johnfitz
cvar_t r_lightmapwide = {"r_lightmapwide","0",CVAR_ROM}; convar r_lightmapwide = {"r_lightmapwide", "0", {.rom = true}};
/* /*
@@ -58,8 +60,7 @@ cvar_t r_lightmapwide = {"r_lightmapwide","0",CVAR_ROM};
GL_Overbright_f -- johnfitz GL_Overbright_f -- johnfitz
==================== ====================
*/ */
static void GL_Overbright_f (cvar_t *var) static void GL_Overbright_f(convar *var) {
{
R_RebuildAllLightmaps(); R_RebuildAllLightmaps();
} }
@@ -68,8 +69,7 @@ static void GL_Overbright_f (cvar_t *var)
GL_Fullbrights_f -- johnfitz GL_Fullbrights_f -- johnfitz
==================== ====================
*/ */
static void GL_Fullbrights_f (cvar_t *var) static void GL_Fullbrights_f(convar *var) {
{
TexMgr_ReloadNobrightImages(); TexMgr_ReloadNobrightImages();
} }
@@ -78,8 +78,7 @@ static void GL_Fullbrights_f (cvar_t *var)
R_SetClearColor_f -- johnfitz R_SetClearColor_f -- johnfitz
==================== ====================
*/ */
static void R_SetClearColor_f (cvar_t *var) static void R_SetClearColor_f(convar *var) {
{
byte *rgb; byte *rgb;
int s; int s;
@@ -93,8 +92,7 @@ static void R_SetClearColor_f (cvar_t *var)
R_Model_ExtraFlags_List_f -- johnfitz -- called when r_nolerp_list or r_noshadow_list cvar changes R_Model_ExtraFlags_List_f -- johnfitz -- called when r_nolerp_list or r_noshadow_list cvar changes
=============== ===============
*/ */
static void R_Model_ExtraFlags_List_f (cvar_t *var) static void R_Model_ExtraFlags_List_f(convar *var) {
{
int i; int i;
for (i = 0; i < MAX_MODELS; i++) for (i = 0; i < MAX_MODELS; i++)
Mod_SetExtraFlags(cl.model_precache[i]); Mod_SetExtraFlags(cl.model_precache[i]);
@@ -105,8 +103,7 @@ static void R_Model_ExtraFlags_List_f (cvar_t *var)
R_SetWateralpha_f -- ericw R_SetWateralpha_f -- ericw
==================== ====================
*/ */
static void R_SetWateralpha_f (cvar_t *var) static void R_SetWateralpha_f(convar *var) {
{
map_wateralpha = var->value; map_wateralpha = var->value;
} }
@@ -115,8 +112,7 @@ static void R_SetWateralpha_f (cvar_t *var)
R_SetLavaalpha_f -- ericw R_SetLavaalpha_f -- ericw
==================== ====================
*/ */
static void R_SetLavaalpha_f (cvar_t *var) static void R_SetLavaalpha_f(convar *var) {
{
map_lavaalpha = var->value; map_lavaalpha = var->value;
} }
@@ -125,8 +121,7 @@ static void R_SetLavaalpha_f (cvar_t *var)
R_SetTelealpha_f -- ericw R_SetTelealpha_f -- ericw
==================== ====================
*/ */
static void R_SetTelealpha_f (cvar_t *var) static void R_SetTelealpha_f(convar *var) {
{
map_telealpha = var->value; map_telealpha = var->value;
} }
@@ -135,8 +130,7 @@ static void R_SetTelealpha_f (cvar_t *var)
R_SetSlimealpha_f -- ericw R_SetSlimealpha_f -- ericw
==================== ====================
*/ */
static void R_SetSlimealpha_f (cvar_t *var) static void R_SetSlimealpha_f(convar *var) {
{
map_slimealpha = var->value; map_slimealpha = var->value;
} }
@@ -145,8 +139,7 @@ static void R_SetSlimealpha_f (cvar_t *var)
GL_WaterAlphaForSurfface -- ericw GL_WaterAlphaForSurfface -- ericw
==================== ====================
*/ */
float GL_WaterAlphaForSurface (msurface_t *fa) float GL_WaterAlphaForSurface(msurface_t *fa) {
{
if (fa->flags & SURF_DRAWLAVA) if (fa->flags & SURF_DRAWLAVA)
return map_lavaalpha > 0 ? map_lavaalpha : map_wateralpha; return map_lavaalpha > 0 ? map_lavaalpha : map_wateralpha;
else if (fa->flags & SURF_DRAWTELE) else if (fa->flags & SURF_DRAWTELE)
@@ -163,73 +156,72 @@ float GL_WaterAlphaForSurface (msurface_t *fa)
R_Init R_Init
=============== ===============
*/ */
void R_Init (void) void R_Init(void) {
{ command::add("timerefresh", R_TimeRefresh_f);
Cmd_AddCommand ("timerefresh", R_TimeRefresh_f); command::add("pointfile", R_ReadPointFile_f);
Cmd_AddCommand ("pointfile", R_ReadPointFile_f);
Cvar_RegisterVariable (&r_norefresh); r_norefresh.inscribe();
Cvar_RegisterVariable (&r_lightmap); r_lightmap.inscribe();
Cvar_RegisterVariable (&r_fullbright); r_fullbright.inscribe();
Cvar_RegisterVariable (&r_drawentities); r_drawentities.inscribe();
Cvar_RegisterVariable (&r_drawviewmodel); r_drawviewmodel.inscribe();
Cvar_RegisterVariable (&r_shadows); r_shadows.inscribe();
Cvar_RegisterVariable (&r_wateralpha); r_wateralpha.inscribe();
Cvar_SetCallback (&r_wateralpha, R_SetWateralpha_f); r_wateralpha.set_callback(R_SetWateralpha_f);
Cvar_RegisterVariable (&r_litwater); r_litwater.inscribe();
Cvar_RegisterVariable (&r_dynamic); r_dynamic.inscribe();
Cvar_RegisterVariable (&r_novis); r_novis.inscribe();
Cvar_RegisterVariable (&r_speeds); r_speeds.inscribe();
Cvar_RegisterVariable (&r_pos); r_pos.inscribe();
Cvar_RegisterVariable (&gl_finish); gl_finish.inscribe();
Cvar_RegisterVariable (&gl_clear); gl_clear.inscribe();
Cvar_RegisterVariable (&gl_cull); gl_cull.inscribe();
Cvar_RegisterVariable (&gl_smoothmodels); gl_smoothmodels.inscribe();
Cvar_RegisterVariable (&gl_affinemodels); gl_affinemodels.inscribe();
Cvar_RegisterVariable (&gl_polyblend); gl_polyblend.inscribe();
Cvar_RegisterVariable (&gl_flashblend); gl_flashblend.inscribe();
Cvar_RegisterVariable (&gl_playermip); gl_playermip.inscribe();
Cvar_RegisterVariable (&gl_nocolors); gl_nocolors.inscribe();
//johnfitz -- new cvars //johnfitz -- new cvars
Cvar_RegisterVariable (&r_stereo); r_stereo.inscribe();
Cvar_RegisterVariable (&r_stereodepth); r_stereodepth.inscribe();
Cvar_RegisterVariable (&r_clearcolor); r_clearcolor.inscribe();
Cvar_SetCallback (&r_clearcolor, R_SetClearColor_f); r_clearcolor.set_callback(R_SetClearColor_f);
Cvar_RegisterVariable (&r_waterquality); r_waterquality.inscribe();
Cvar_RegisterVariable (&r_oldwater); r_oldwater.inscribe();
Cvar_RegisterVariable (&r_waterwarp); r_waterwarp.inscribe();
Cvar_RegisterVariable (&r_drawflat); r_drawflat.inscribe();
Cvar_RegisterVariable (&r_flatlightstyles); r_flatlightstyles.inscribe();
Cvar_RegisterVariable (&r_oldskyleaf); r_oldskyleaf.inscribe();
Cvar_RegisterVariable (&r_drawworld); r_drawworld.inscribe();
Cvar_RegisterVariable (&r_showtris); r_showtris.inscribe();
Cvar_RegisterVariable (&r_showbboxes); r_showbboxes.inscribe();
Cvar_RegisterVariable (&gl_farclip); gl_farclip.inscribe();
Cvar_RegisterVariable (&gl_fullbrights); gl_fullbrights.inscribe();
Cvar_RegisterVariable (&gl_overbright); gl_overbright.inscribe();
Cvar_SetCallback (&gl_fullbrights, GL_Fullbrights_f); gl_fullbrights.set_callback(GL_Fullbrights_f);
Cvar_SetCallback (&gl_overbright, GL_Overbright_f); gl_overbright.set_callback(GL_Overbright_f);
Cvar_RegisterVariable (&gl_overbright_models); gl_overbright_models.inscribe();
Cvar_RegisterVariable (&r_lerpmodels); r_lerpmodels.inscribe();
Cvar_RegisterVariable (&r_lerpmove); r_lerpmove.inscribe();
Cvar_RegisterVariable (&r_nolerp_list); r_nolerp_list.inscribe();
Cvar_SetCallback (&r_nolerp_list, R_Model_ExtraFlags_List_f); r_nolerp_list.set_callback(R_Model_ExtraFlags_List_f);
Cvar_RegisterVariable (&r_noshadow_list); r_noshadow_list.inscribe();
Cvar_SetCallback (&r_noshadow_list, R_Model_ExtraFlags_List_f); r_noshadow_list.set_callback(R_Model_ExtraFlags_List_f);
//johnfitz //johnfitz
Cvar_RegisterVariable (&r_lightmapwide); r_lightmapwide.inscribe();
Cvar_SetROM ("r_lightmapwide", gl_packed_pixels ? "1" : "0"); convar::set_rom("r_lightmapwide", gl_packed_pixels ? "1" : "0");
Cvar_RegisterVariable (&gl_zfix); // QuakeSpasm z-fighting fix gl_zfix.inscribe(); // QuakeSpasm z-fighting fix
Cvar_RegisterVariable (&r_lavaalpha); r_lavaalpha.inscribe();
Cvar_RegisterVariable (&r_telealpha); r_telealpha.inscribe();
Cvar_RegisterVariable (&r_slimealpha); r_slimealpha.inscribe();
Cvar_RegisterVariable (&r_scale); r_scale.inscribe();
Cvar_SetCallback (&r_lavaalpha, R_SetLavaalpha_f); r_lavaalpha.set_callback(R_SetLavaalpha_f);
Cvar_SetCallback (&r_telealpha, R_SetTelealpha_f); r_telealpha.set_callback(R_SetTelealpha_f);
Cvar_SetCallback (&r_slimealpha, R_SetSlimealpha_f); r_slimealpha.set_callback(R_SetSlimealpha_f);
R_InitParticles(); R_InitParticles();
R_SetClearColor_f(&r_clearcolor); //johnfitz R_SetClearColor_f(&r_clearcolor); //johnfitz
@@ -243,16 +235,14 @@ void R_Init (void)
R_TranslatePlayerSkin -- johnfitz -- rewritten. also, only handles new colors, not new skins R_TranslatePlayerSkin -- johnfitz -- rewritten. also, only handles new colors, not new skins
=============== ===============
*/ */
void R_TranslatePlayerSkin (int playernum) void R_TranslatePlayerSkin(int playernum) {
{
int top, bottom; int top, bottom;
top = (cl.scores[playernum].colors & 0xf0) >> 4; top = (cl.scores[playernum].colors & 0xf0) >> 4;
bottom = cl.scores[playernum].colors & 15; bottom = cl.scores[playernum].colors & 15;
//FIXME: if gl_nocolors is on, then turned off, the textures may be out of sync with the scoreboard colors. //FIXME: if gl_nocolors is on, then turned off, the textures may be out of sync with the scoreboard colors.
if (!gl_nocolors.value) if (!gl_nocolors.value) {
{
if (playertextures[playernum]) if (playertextures[playernum])
TexMgr_ReloadImage(playertextures[playernum], top, bottom); TexMgr_ReloadImage(playertextures[playernum], top, bottom);
} }
@@ -265,8 +255,7 @@ the skin or model actually changes, instead of just new colors
added bug fix from bengt jardup added bug fix from bengt jardup
=============== ===============
*/ */
void R_TranslateNewPlayerSkin (int playernum) void R_TranslateNewPlayerSkin(int playernum) {
{
char name[64]; char name[64];
byte *pixels; byte *pixels;
aliashdr_t *paliashdr; aliashdr_t *paliashdr;
@@ -283,8 +272,7 @@ void R_TranslateNewPlayerSkin (int playernum)
skinnum = currententity->skinnum; skinnum = currententity->skinnum;
//TODO: move these tests to the place where skinnum gets received from the server //TODO: move these tests to the place where skinnum gets received from the server
if (skinnum < 0 || skinnum >= paliashdr->numskins) if (skinnum < 0 || skinnum >= paliashdr->numskins) {
{
Con_DPrintf("(%d): Invalid player skin #%d\n", playernum, skinnum); Con_DPrintf("(%d): Invalid player skin #%d\n", playernum, skinnum);
skinnum = 0; skinnum = 0;
} }
@@ -293,8 +281,11 @@ void R_TranslateNewPlayerSkin (int playernum)
//upload new image //upload new image
q_snprintf(name, sizeof(name), "player_%i", playernum); q_snprintf(name, sizeof(name), "player_%i", playernum);
playertextures[playernum] = TexMgr_LoadImage (currententity->model, name, paliashdr->skinwidth, paliashdr->skinheight, playertextures[playernum] = TexMgr_LoadImage(currententity->model, name, paliashdr->skinwidth,
SRC_INDEXED, pixels, paliashdr->gltextures[skinnum][0]->source_file, paliashdr->gltextures[skinnum][0]->source_offset, TEXPREF_PAD | TEXPREF_OVERWRITE); paliashdr->skinheight,
SRC_INDEXED, pixels, paliashdr->gltextures[skinnum][0]->source_file,
paliashdr->gltextures[skinnum][0]->source_offset,
TEXPREF_PAD | TEXPREF_OVERWRITE);
//now recolor it //now recolor it
R_TranslatePlayerSkin(playernum); R_TranslatePlayerSkin(playernum);
@@ -305,8 +296,7 @@ void R_TranslateNewPlayerSkin (int playernum)
R_NewGame -- johnfitz -- handle a game switch R_NewGame -- johnfitz -- handle a game switch
=============== ===============
*/ */
void R_NewGame (void) void R_NewGame(void) {
{
int i; int i;
//clear playertexture pointers (the textures themselves were freed by texmgr_newgame) //clear playertexture pointers (the textures themselves were freed by texmgr_newgame)
@@ -321,51 +311,60 @@ R_ParseWorldspawn
called at map load called at map load
============= =============
*/ */
static void R_ParseWorldspawn (void) static void R_ParseWorldspawn() {
{
char key[128], value[4096];
const char *data;
map_wateralpha = r_wateralpha.value; map_wateralpha = r_wateralpha.value;
map_lavaalpha = r_lavaalpha.value; map_lavaalpha = r_lavaalpha.value;
map_telealpha = r_telealpha.value; map_telealpha = r_telealpha.value;
map_slimealpha = r_slimealpha.value; map_slimealpha = r_slimealpha.value;
data = COM_Parse(cl.worldmodel->entities); std::string key{};
if (!data) std::string value{};
std::istringstream ss{cl.worldmodel->entities};
auto token = common::parse_token(ss);
if (!token.has_value())
return; // error return; // error
if (com_token[0] != '{') if ((*token)[0] != '{')
return; // error return; // error
while (1) while (true) {
{ token = common::parse_token(ss);
data = COM_Parse(data); if (!token.has_value()) {
if (!data)
return; // error return; // error
if (com_token[0] == '}') }
if ((*token)[0] == '}') {
break; // end of worldspawn break; // end of worldspawn
if (com_token[0] == '_') }
q_strlcpy(key, com_token + 1, sizeof(key)); if ((*token)[0] == '_') {
else key = token->substr(1);
q_strlcpy(key, com_token, sizeof(key)); } else {
while (key[0] && key[strlen(key)-1] == ' ') // remove trailing spaces key = *token;
key[strlen(key)-1] = 0; }
data = COM_ParseEx(data, CPE_ALLOWTRUNC); while (!key.empty() && key.back() == ' ') {
if (!data) // remove trailing spaces
key.pop_back();
}
token = common::parse_token(ss);
if (!token.has_value()) {
return; // error return; // error
q_strlcpy(value, com_token, sizeof(value)); }
value = *token;
if (!strcmp("wateralpha", key)) if (key == "wateralpha") {
map_wateralpha = atof(value); map_wateralpha = std::strtof(value.c_str(), nullptr);
}
if (!strcmp("lavaalpha", key)) if (key == "lavaalpha") {
map_lavaalpha = atof(value); map_lavaalpha = std::strtof(value.c_str(), nullptr);
}
if (!strcmp("telealpha", key)) if (key == "telealpha") {
map_telealpha = atof(value); map_telealpha = std::strtof(value.c_str(), nullptr);
}
if (!strcmp("slimealpha", key)) if (key == "slimealpha") {
map_slimealpha = atof(value); map_slimealpha = std::strtof(value.c_str(), nullptr);
}
} }
} }
@@ -375,8 +374,7 @@ static void R_ParseWorldspawn (void)
R_NewMap R_NewMap
=============== ===============
*/ */
void R_NewMap (void) void R_NewMap(void) {
{
int i; int i;
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
@@ -411,20 +409,17 @@ R_TimeRefresh_f
For program optimization For program optimization
==================== ====================
*/ */
void R_TimeRefresh_f (void) void R_TimeRefresh_f(void) {
{
int i; int i;
float start, stop, time; float start, stop, time;
if (cls.state != ca_connected) if (cls.state != ca_connected) {
{
Con_Printf("Not connected to a server\n"); Con_Printf("Not connected to a server\n");
return; return;
} }
start = Sys_DoubleTime(); start = Sys_DoubleTime();
for (i = 0; i < 128; i++) for (i = 0; i < 128; i++) {
{
GL_BeginRendering(&glx, &gly, &glwidth, &glheight); GL_BeginRendering(&glx, &gly, &glwidth, &glheight);
r_refdef.viewangles[1] = i / 128.0 * 360.0; r_refdef.viewangles[1] = i / 128.0 * 360.0;
R_RenderView(); R_RenderView();
@@ -437,20 +432,17 @@ void R_TimeRefresh_f (void)
Con_Printf("%f seconds (%f fps)\n", time, 128 / time); Con_Printf("%f seconds (%f fps)\n", time, 128 / time);
} }
void D_FlushCaches (void) void D_FlushCaches(void) {
{
} }
static GLuint gl_programs[16]; static GLuint gl_programs[16];
static int gl_num_programs; static int gl_num_programs;
static qboolean GL_CheckShader (GLuint shader) static qboolean GL_CheckShader(GLuint shader) {
{
GLint status; GLint status;
GL_GetShaderivFunc(shader, GL_COMPILE_STATUS, &status); GL_GetShaderivFunc(shader, GL_COMPILE_STATUS, &status);
if (status != GL_TRUE) if (status != GL_TRUE) {
{
char infolog[1024]; char infolog[1024];
memset(infolog, 0, sizeof(infolog)); memset(infolog, 0, sizeof(infolog));
@@ -463,13 +455,11 @@ static qboolean GL_CheckShader (GLuint shader)
return true; return true;
} }
static qboolean GL_CheckProgram (GLuint program) static qboolean GL_CheckProgram(GLuint program) {
{
GLint status; GLint status;
GL_GetProgramivFunc(program, GL_LINK_STATUS, &status); GL_GetProgramivFunc(program, GL_LINK_STATUS, &status);
if (status != GL_TRUE) if (status != GL_TRUE) {
{
char infolog[1024]; char infolog[1024];
memset(infolog, 0, sizeof(infolog)); memset(infolog, 0, sizeof(infolog));
@@ -487,16 +477,14 @@ static qboolean GL_CheckProgram (GLuint program)
GL_GetUniformLocation GL_GetUniformLocation
============= =============
*/ */
GLint GL_GetUniformLocation (GLuint *programPtr, const char *name) GLint GL_GetUniformLocation(GLuint *programPtr, const char *name) {
{
GLint location; GLint location;
if (!programPtr) if (!programPtr)
return -1; return -1;
location = GL_GetUniformLocationFunc(*programPtr, name); location = GL_GetUniformLocationFunc(*programPtr, name);
if (location == -1) if (location == -1) {
{
Con_Warning("GL_GetUniformLocationFunc %s failed\n", name); Con_Warning("GL_GetUniformLocationFunc %s failed\n", name);
*programPtr = 0; *programPtr = 0;
} }
@@ -510,8 +498,8 @@ GL_CreateProgram
Compiles and returns GLSL program. Compiles and returns GLSL program.
==================== ====================
*/ */
GLuint GL_CreateProgram (const GLchar *vertSource, const GLchar *fragSource, int numbindings, const glsl_attrib_binding_t *bindings) GLuint GL_CreateProgram(const GLchar *vertSource, const GLchar *fragSource, int numbindings,
{ const glsl_attrib_binding_t *bindings) {
int i; int i;
GLuint program, vertShader, fragShader; GLuint program, vertShader, fragShader;
@@ -521,8 +509,7 @@ GLuint GL_CreateProgram (const GLchar *vertSource, const GLchar *fragSource, int
vertShader = GL_CreateShaderFunc(GL_VERTEX_SHADER); vertShader = GL_CreateShaderFunc(GL_VERTEX_SHADER);
GL_ShaderSourceFunc(vertShader, 1, &vertSource, NULL); GL_ShaderSourceFunc(vertShader, 1, &vertSource, NULL);
GL_CompileShaderFunc(vertShader); GL_CompileShaderFunc(vertShader);
if (!GL_CheckShader (vertShader)) if (!GL_CheckShader(vertShader)) {
{
GL_DeleteShaderFunc(vertShader); GL_DeleteShaderFunc(vertShader);
return 0; return 0;
} }
@@ -530,8 +517,7 @@ GLuint GL_CreateProgram (const GLchar *vertSource, const GLchar *fragSource, int
fragShader = GL_CreateShaderFunc(GL_FRAGMENT_SHADER); fragShader = GL_CreateShaderFunc(GL_FRAGMENT_SHADER);
GL_ShaderSourceFunc(fragShader, 1, &fragSource, NULL); GL_ShaderSourceFunc(fragShader, 1, &fragSource, NULL);
GL_CompileShaderFunc(fragShader); GL_CompileShaderFunc(fragShader);
if (!GL_CheckShader (fragShader)) if (!GL_CheckShader(fragShader)) {
{
GL_DeleteShaderFunc(vertShader); GL_DeleteShaderFunc(vertShader);
GL_DeleteShaderFunc(fragShader); GL_DeleteShaderFunc(fragShader);
return 0; return 0;
@@ -543,20 +529,16 @@ GLuint GL_CreateProgram (const GLchar *vertSource, const GLchar *fragSource, int
GL_AttachShaderFunc(program, fragShader); GL_AttachShaderFunc(program, fragShader);
GL_DeleteShaderFunc(fragShader); GL_DeleteShaderFunc(fragShader);
for (i = 0; i < numbindings; i++) for (i = 0; i < numbindings; i++) {
{
GL_BindAttribLocationFunc(program, bindings[i].attrib, bindings[i].name); GL_BindAttribLocationFunc(program, bindings[i].attrib, bindings[i].name);
} }
GL_LinkProgramFunc(program); GL_LinkProgramFunc(program);
if (!GL_CheckProgram (program)) if (!GL_CheckProgram(program)) {
{
GL_DeleteProgramFunc(program); GL_DeleteProgramFunc(program);
return 0; return 0;
} } else {
else
{
if (gl_num_programs == Q_COUNTOF(gl_programs)) if (gl_num_programs == Q_COUNTOF(gl_programs))
Host_Error("gl_programs overflow"); Host_Error("gl_programs overflow");
@@ -574,15 +556,13 @@ R_DeleteShaders
Deletes any GLSL programs that have been created. Deletes any GLSL programs that have been created.
==================== ====================
*/ */
void R_DeleteShaders (void) void R_DeleteShaders(void) {
{
int i; int i;
if (!gl_glsl_able) if (!gl_glsl_able)
return; return;
for (i = 0; i < gl_num_programs; i++) for (i = 0; i < gl_num_programs; i++) {
{
GL_DeleteProgramFunc(gl_programs[i]); GL_DeleteProgramFunc(gl_programs[i]);
gl_programs[i] = 0; gl_programs[i] = 0;
} }
@@ -598,15 +578,13 @@ GL_BindBuffer
glBindBuffer wrapper glBindBuffer wrapper
==================== ====================
*/ */
void GL_BindBuffer (GLenum target, GLuint buffer) void GL_BindBuffer(GLenum target, GLuint buffer) {
{
GLuint *cache; GLuint *cache;
if (!gl_vbo_able) if (!gl_vbo_able)
return; return;
switch (target) switch (target) {
{
case GL_ARRAY_BUFFER: case GL_ARRAY_BUFFER:
cache = &current_array_buffer; cache = &current_array_buffer;
break; break;
@@ -618,8 +596,7 @@ void GL_BindBuffer (GLenum target, GLuint buffer)
return; return;
} }
if (*cache != buffer) if (*cache != buffer) {
{
*cache = buffer; *cache = buffer;
GL_BindBufferFunc(target, *cache); GL_BindBufferFunc(target, *cache);
} }
@@ -633,8 +610,7 @@ This must be called if you do anything that could make the cached bindings
invalid (e.g. manually binding, destroying the context). invalid (e.g. manually binding, destroying the context).
==================== ====================
*/ */
void GL_ClearBufferBindings (void) void GL_ClearBufferBindings(void) {
{
if (!gl_vbo_able) if (!gl_vbo_able)
return; return;
+64 -64
View File
@@ -78,30 +78,30 @@ float scr_con_current;
float scr_conlines; // lines of console to display float scr_conlines; // lines of console to display
//johnfitz -- new cvars //johnfitz -- new cvars
cvar_t scr_menuscale = {"scr_menuscale", "1", CVAR_ARCHIVE}; convar scr_menuscale = {"scr_menuscale", "1", {.archive = true}};
cvar_t scr_sbarscale = {"scr_sbarscale", "1", CVAR_ARCHIVE}; convar scr_sbarscale = {"scr_sbarscale", "1", {.archive = true}};
cvar_t scr_sbaralpha = {"scr_sbaralpha", "0.75", CVAR_ARCHIVE}; convar scr_sbaralpha = {"scr_sbaralpha", "0.75", {.archive = true}};
cvar_t scr_conwidth = {"scr_conwidth", "0", CVAR_ARCHIVE}; convar scr_conwidth = {"scr_conwidth", "0", {.archive = true}};
cvar_t scr_conscale = {"scr_conscale", "1", CVAR_ARCHIVE}; convar scr_conscale = {"scr_conscale", "1", {.archive = true}};
cvar_t scr_crosshairscale = {"scr_crosshairscale", "1", CVAR_ARCHIVE}; convar scr_crosshairscale = {"scr_crosshairscale", "1", {.archive = true}};
cvar_t scr_showfps = {"scr_showfps", "0", CVAR_NONE}; convar scr_showfps = {"scr_showfps", "0"};
cvar_t scr_clock = {"scr_clock", "0", CVAR_NONE}; convar scr_clock = {"scr_clock", "0"};
//johnfitz //johnfitz
cvar_t scr_usekfont = {"scr_usekfont", "0", CVAR_NONE}; // 2021 re-release convar scr_usekfont = {"scr_usekfont", "0"}; // 2021 re-release
cvar_t scr_viewsize = {"viewsize","100", CVAR_ARCHIVE}; convar scr_viewsize = {"viewsize","100", {.archive = true}};
cvar_t scr_fov = {"fov","90",CVAR_NONE}; // 10 - 170 convar scr_fov = {"fov","90"}; // 10 - 170
cvar_t scr_fov_adapt = {"fov_adapt","1",CVAR_ARCHIVE}; convar scr_fov_adapt = {"fov_adapt","1",{.archive = true}};
cvar_t scr_conspeed = {"scr_conspeed","500",CVAR_ARCHIVE}; convar scr_conspeed = {"scr_conspeed","500",{.archive = true}};
cvar_t scr_centertime = {"scr_centertime","2",CVAR_NONE}; convar scr_centertime = {"scr_centertime","2"};
cvar_t scr_showturtle = {"showturtle","0",CVAR_NONE}; convar scr_showturtle = {"showturtle","0"};
cvar_t scr_showpause = {"showpause","1",CVAR_NONE}; convar scr_showpause = {"showpause","1"};
cvar_t scr_printspeed = {"scr_printspeed","8",CVAR_NONE}; convar scr_printspeed = {"scr_printspeed","8"};
cvar_t gl_triplebuffer = {"gl_triplebuffer", "1", CVAR_ARCHIVE}; convar gl_triplebuffer = {"gl_triplebuffer", "1", {.archive = true}};
cvar_t cl_gun_fovscale = {"cl_gun_fovscale","1",CVAR_ARCHIVE}; // Qrack convar cl_gun_fovscale = {"cl_gun_fovscale","1",{.archive = true}}; // Qrack
extern cvar_t crosshair; extern convar crosshair;
qboolean scr_initialized; // ready to draw qboolean scr_initialized; // ready to draw
@@ -291,15 +291,15 @@ static void SCR_CalcRefdef (void)
// bound viewsize // bound viewsize
if (scr_viewsize.value < 30) if (scr_viewsize.value < 30)
Cvar_SetQuick (&scr_viewsize, "30"); scr_viewsize.set("30");
if (scr_viewsize.value > 120) if (scr_viewsize.value > 120)
Cvar_SetQuick (&scr_viewsize, "120"); scr_viewsize.set("120");
// bound fov // bound fov
if (scr_fov.value < 10) if (scr_fov.value < 10)
Cvar_SetQuick (&scr_fov, "10"); scr_fov.set("10");
if (scr_fov.value > 170) if (scr_fov.value > 170)
Cvar_SetQuick (&scr_fov, "170"); scr_fov.set("170");
vid.recalc_refdef = 0; vid.recalc_refdef = 0;
@@ -314,12 +314,12 @@ static void SCR_CalcRefdef (void)
else else
sb_lines = 48 * scale; sb_lines = 48 * scale;
size = q_min(scr_viewsize.value, 100.f) / 100; size = std::min(scr_viewsize.value, 100.f) / 100;
//johnfitz //johnfitz
//johnfitz -- rewrote this section //johnfitz -- rewrote this section
r_refdef.vrect.width = q_max(glwidth * size, 96.0f); //no smaller than 96, for icons r_refdef.vrect.width = std::max(glwidth * size, 96.0f); //no smaller than 96, for icons
r_refdef.vrect.height = q_min((int)(glheight * size), glheight - sb_lines); //make room for sbar r_refdef.vrect.height = std::min((int)(glheight * size), glheight - sb_lines); //make room for sbar
r_refdef.vrect.x = (glwidth - r_refdef.vrect.width)/2; r_refdef.vrect.x = (glwidth - r_refdef.vrect.width)/2;
r_refdef.vrect.y = (glheight - sb_lines - r_refdef.vrect.height)/2; r_refdef.vrect.y = (glheight - sb_lines - r_refdef.vrect.height)/2;
//johnfitz //johnfitz
@@ -340,7 +340,7 @@ Keybinding command
*/ */
void SCR_SizeUp_f (void) void SCR_SizeUp_f (void)
{ {
Cvar_SetValueQuick (&scr_viewsize, scr_viewsize.value+10); scr_viewsize.set_value(scr_viewsize.value+10);
} }
@@ -353,10 +353,10 @@ Keybinding command
*/ */
void SCR_SizeDown_f (void) void SCR_SizeDown_f (void)
{ {
Cvar_SetValueQuick (&scr_viewsize, scr_viewsize.value-10); scr_viewsize.set_value(scr_viewsize.value-10);
} }
static void SCR_Callback_refdef (cvar_t *var) static void SCR_Callback_refdef (convar *var)
{ {
vid.recalc_refdef = 1; vid.recalc_refdef = 1;
} }
@@ -366,7 +366,7 @@ static void SCR_Callback_refdef (cvar_t *var)
SCR_Conwidth_f -- johnfitz -- called when scr_conwidth or scr_conscale changes SCR_Conwidth_f -- johnfitz -- called when scr_conwidth or scr_conscale changes
================== ==================
*/ */
void SCR_Conwidth_f (cvar_t *var) void SCR_Conwidth_f (convar *var)
{ {
vid.recalc_refdef = 1; vid.recalc_refdef = 1;
vid.conwidth = (scr_conwidth.value > 0) ? (int)scr_conwidth.value : (scr_conscale.value > 0) ? (int)(vid.width/scr_conscale.value) : vid.width; vid.conwidth = (scr_conwidth.value > 0) ? (int)scr_conwidth.value : (scr_conscale.value > 0) ? (int)(vid.width/scr_conscale.value) : vid.width;
@@ -396,36 +396,36 @@ SCR_Init
void SCR_Init (void) void SCR_Init (void)
{ {
//johnfitz -- new cvars //johnfitz -- new cvars
Cvar_RegisterVariable (&scr_menuscale); scr_menuscale.inscribe();
Cvar_RegisterVariable (&scr_sbarscale); scr_sbarscale.inscribe();
Cvar_SetCallback (&scr_sbaralpha, SCR_Callback_refdef); scr_sbaralpha.set_callback(SCR_Callback_refdef);
Cvar_RegisterVariable (&scr_sbaralpha); scr_sbaralpha.inscribe();
Cvar_SetCallback (&scr_conwidth, &SCR_Conwidth_f); scr_conwidth.set_callback(&SCR_Conwidth_f);
Cvar_SetCallback (&scr_conscale, &SCR_Conwidth_f); scr_conscale.set_callback(&SCR_Conwidth_f);
Cvar_RegisterVariable (&scr_conwidth); scr_conwidth.inscribe();
Cvar_RegisterVariable (&scr_conscale); scr_conscale.inscribe();
Cvar_RegisterVariable (&scr_crosshairscale); scr_crosshairscale.inscribe();
Cvar_RegisterVariable (&scr_showfps); scr_showfps.inscribe();
Cvar_RegisterVariable (&scr_clock); scr_clock.inscribe();
//johnfitz //johnfitz
Cvar_RegisterVariable (&scr_usekfont); // 2021 re-release scr_usekfont.inscribe(); // 2021 re-release
Cvar_SetCallback (&scr_fov, SCR_Callback_refdef); scr_fov.set_callback(SCR_Callback_refdef);
Cvar_SetCallback (&scr_fov_adapt, SCR_Callback_refdef); scr_fov_adapt.set_callback(SCR_Callback_refdef);
Cvar_SetCallback (&scr_viewsize, SCR_Callback_refdef); scr_viewsize.set_callback(SCR_Callback_refdef);
Cvar_RegisterVariable (&scr_fov); scr_fov.inscribe();
Cvar_RegisterVariable (&scr_fov_adapt); scr_fov_adapt.inscribe();
Cvar_RegisterVariable (&scr_viewsize); scr_viewsize.inscribe();
Cvar_RegisterVariable (&scr_conspeed); scr_conspeed.inscribe();
Cvar_RegisterVariable (&scr_showturtle); scr_showturtle.inscribe();
Cvar_RegisterVariable (&scr_showpause); scr_showpause.inscribe();
Cvar_RegisterVariable (&scr_centertime); scr_centertime.inscribe();
Cvar_RegisterVariable (&scr_printspeed); scr_printspeed.inscribe();
Cvar_RegisterVariable (&gl_triplebuffer); gl_triplebuffer.inscribe();
Cvar_RegisterVariable (&cl_gun_fovscale); cl_gun_fovscale.inscribe();
Cmd_AddCommand ("screenshot",SCR_ScreenShot_f); command::add ("screenshot",SCR_ScreenShot_f);
Cmd_AddCommand ("sizeup",SCR_SizeUp_f); command::add ("sizeup",SCR_SizeUp_f);
Cmd_AddCommand ("sizedown",SCR_SizeDown_f); command::add ("sizedown",SCR_SizeDown_f);
SCR_LoadPics (); //johnfitz SCR_LoadPics (); //johnfitz
@@ -666,7 +666,7 @@ SCR_SetUpToDrawConsole
void SCR_SetUpToDrawConsole (void) void SCR_SetUpToDrawConsole (void)
{ {
//johnfitz -- let's hack away the problem of slow console when host_timescale is <0 //johnfitz -- let's hack away the problem of slow console when host_timescale is <0
extern cvar_t host_timescale; extern convar host_timescale;
float timescale, conspeed; float timescale, conspeed;
//johnfitz //johnfitz
@@ -765,9 +765,9 @@ void SCR_ScreenShot_f (void)
Q_strncpy (ext, "png", sizeof(ext)); Q_strncpy (ext, "png", sizeof(ext));
if (Cmd_Argc () >= 2) if (command::argc () >= 2)
{ {
const char *requested_ext = Cmd_Argv (1); const char *requested_ext = command::argv (1)->c_str();
if (!q_strcasecmp ("png", requested_ext) if (!q_strcasecmp ("png", requested_ext)
|| !q_strcasecmp ("tga", requested_ext) || !q_strcasecmp ("tga", requested_ext)
@@ -782,8 +782,8 @@ void SCR_ScreenShot_f (void)
// read quality as the 3rd param (only used for JPG) // read quality as the 3rd param (only used for JPG)
quality = 90; quality = 90;
if (Cmd_Argc () >= 3) if (command::argc () >= 3)
quality = Q_atoi (Cmd_Argv(2)); quality = Q_atoi (command::argv(2)->c_str());
if (quality < 1 || quality > 100) if (quality < 1 || quality > 100)
{ {
SCR_ScreenShot_Usage (); SCR_ScreenShot_Usage ();
+55 -46
View File
@@ -22,6 +22,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
//gl_sky.c //gl_sky.c
#include <sstream>
#include "quakedef.hpp" #include "quakedef.hpp"
#define MAX_CLIP_VERTS 64 #define MAX_CLIP_VERTS 64
@@ -40,11 +42,11 @@ static char skybox_name[1024]; //name of current skybox, or "" if no skybox
static gltexture_t *skybox_textures[6]; static gltexture_t *skybox_textures[6];
static gltexture_t *solidskytexture, *alphaskytexture; static gltexture_t *solidskytexture, *alphaskytexture;
extern cvar_t gl_farclip; extern convar gl_farclip;
static cvar_t r_fastsky = {"r_fastsky", "0", CVAR_NONE}; static convar r_fastsky{"r_fastsky", "0"};
static cvar_t r_sky_quality = {"r_sky_quality", "12", CVAR_NONE}; static convar r_sky_quality{"r_sky_quality", "12"};
static cvar_t r_skyalpha = {"r_skyalpha", "1", CVAR_NONE}; static convar r_skyalpha{"r_skyalpha", "1"};
static cvar_t r_skyfog = {"r_skyfog","0.5",CVAR_NONE}; static convar r_skyfog{"r_skyfog","0.5"};
static const int skytexorder[6] = {0,2,1,3,4,5}; //for skybox static const int skytexorder[6] = {0,2,1,3,4,5}; //for skybox
@@ -298,53 +300,60 @@ Sky_NewMap
*/ */
void Sky_NewMap (void) void Sky_NewMap (void)
{ {
char key[128], value[4096];
const char *data;
skyfog = r_skyfog.value; skyfog = r_skyfog.value;
std::string key{};
std::string value{};
// //
// read worldspawn (this is so ugly, and shouldn't it be done on the server?) // read worldspawn (this is so ugly, and shouldn't it be done on the server?)
// //
data = cl.worldmodel->entities; std::istringstream ss{cl.worldmodel->entities};
if (!data) if (ss.eof())
return; //FIXME: how could this possibly ever happen? -- if there's no return; //FIXME: how could this possibly ever happen? -- if there's no
// worldspawn then the sever wouldn't send the loadmap message to the client // worldspawn then the sever wouldn't send the loadmap message to the client
data = COM_Parse(data); auto token = common::parse_token(ss);
if (!data) //should never happen if (!token.has_value()) {
//should never happen
return; // error return; // error
if (com_token[0] != '{') //should never happen }
if (token->front() != '{') {
//should never happen
return; // error return; // error
while (1) }
while (true)
{ {
data = COM_Parse(data); token = common::parse_token(ss);
if (!data) if (!token.has_value()) {
return; // error return; // error
if (com_token[0] == '}') }
if (token->front() == '}') {
break; // end of worldspawn break; // end of worldspawn
if (com_token[0] == '_') }
q_strlcpy(key, com_token + 1, sizeof(key)); if (token->front() == '_') {
else key = token->substr(1);
q_strlcpy(key, com_token, sizeof(key)); }
while (key[0] && key[strlen(key)-1] == ' ') // remove trailing spaces else {
key[strlen(key)-1] = 0; key = token.value();
data = COM_ParseEx(data, CPE_ALLOWTRUNC); }
if (!data) while (!key.empty() && key.back() == ' ') {
key.pop_back();
}
token = common::parse_token(ss);
if (!token.has_value()) {
return; // error return; // error
q_strlcpy(value, com_token, sizeof(value)); }
value = token.value();
if (!strcmp("sky", key)) if (key == "sky" || key == "skyname" || key == "qlsky") {
Sky_LoadSkyBox(value); Sky_LoadSkyBox(value.c_str());
}
if (!strcmp("skyfog", key)) if (key == "skyfog") {
skyfog = atof(value); skyfog = std::strtof(value.c_str(), nullptr);
#if 1 /* also accept non-standard keys */ }
else if (!strcmp("skyname", key)) //half-life
Sky_LoadSkyBox(value);
else if (!strcmp("qlsky", key)) //quake lives
Sky_LoadSkyBox(value);
#endif
} }
} }
@@ -355,13 +364,13 @@ Sky_SkyCommand_f
*/ */
void Sky_SkyCommand_f (void) void Sky_SkyCommand_f (void)
{ {
switch (Cmd_Argc()) switch (command::argc())
{ {
case 1: case 1:
Con_Printf("\"sky\" is \"%s\"\n", skybox_name); Con_Printf("\"sky\" is \"%s\"\n", skybox_name);
break; break;
case 2: case 2:
Sky_LoadSkyBox(Cmd_Argv(1)); Sky_LoadSkyBox(command::argv(1)->c_str());
break; break;
default: default:
Con_Printf("usage: sky <skyname>\n"); Con_Printf("usage: sky <skyname>\n");
@@ -373,7 +382,7 @@ void Sky_SkyCommand_f (void)
R_SetSkyfog_f -- ericw R_SetSkyfog_f -- ericw
==================== ====================
*/ */
static void R_SetSkyfog_f (cvar_t *var) static void R_SetSkyfog_f (convar *var)
{ {
// clear any skyfog setting from worldspawn // clear any skyfog setting from worldspawn
skyfog = var->value; skyfog = var->value;
@@ -388,13 +397,13 @@ void Sky_Init (void)
{ {
int i; int i;
Cvar_RegisterVariable (&r_fastsky); r_fastsky.inscribe();
Cvar_RegisterVariable (&r_sky_quality); r_sky_quality.inscribe();
Cvar_RegisterVariable (&r_skyalpha); r_skyalpha.inscribe();
Cvar_RegisterVariable (&r_skyfog); r_skyfog.inscribe();
Cvar_SetCallback (&r_skyfog, R_SetSkyfog_f); r_skyfog.set_callback(R_SetSkyfog_f);
Cmd_AddCommand ("sky",Sky_SkyCommand_f); command::add ("sky",Sky_SkyCommand_f);
skybox_name[0] = 0; skybox_name[0] = 0;
for (i=0; i<6; i++) for (i=0; i<6; i++)
@@ -1020,7 +1029,7 @@ void Sky_DrawFace (int axis)
VectorSubtract(verts[2],verts[3],up); VectorSubtract(verts[2],verts[3],up);
VectorSubtract(verts[2],verts[1],right); VectorSubtract(verts[2],verts[1],right);
di = q_max((int)r_sky_quality.value, 1); di = std::max((int)r_sky_quality.value, 1);
qi = 1.0 / di; qi = 1.0 / di;
dj = (axis < 4) ? di*2 : di; //subdivide vertically more than horizontally on skybox sides dj = (axis < 4) ? di*2 : di; //subdivide vertically more than horizontally on skybox sides
qj = 1.0 / dj; qj = 1.0 / dj;
+235 -313
View File
File diff suppressed because it is too large Load Diff
+262 -418
View File
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -22,11 +22,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "quakedef.hpp" #include "quakedef.hpp"
extern cvar_t r_drawflat; extern convar r_drawflat;
cvar_t r_oldwater = {"r_oldwater", "0", CVAR_ARCHIVE}; convar r_oldwater{"r_oldwater", "0", {.archive = true}};
cvar_t r_waterquality = {"r_waterquality", "8", CVAR_NONE}; convar r_waterquality{"r_waterquality", "8"};
cvar_t r_waterwarp = {"r_waterwarp", "1", CVAR_NONE}; convar r_waterwarp{"r_waterwarp", "1"};
int gl_warpimagesize; int gl_warpimagesize;
float load_subdivide_size; //johnfitz -- remember what subdivide_size value was when this map was loaded float load_subdivide_size; //johnfitz -- remember what subdivide_size value was when this map was loaded
@@ -46,7 +46,7 @@ static const float turbsin[] = {
static msurface_t *warpface; static msurface_t *warpface;
cvar_t gl_subdivide_size = {"gl_subdivide_size", "128", CVAR_ARCHIVE}; convar gl_subdivide_size{"gl_subdivide_size", "128", {.archive = true}};
static void BoundPoly (int numverts, float *verts, vec3_t mins, vec3_t maxs) static void BoundPoly (int numverts, float *verts, vec3_t mins, vec3_t maxs)
{ {
+30 -30
View File
@@ -125,38 +125,38 @@ extern refdef_t r_refdef;
extern mleaf_t *r_viewleaf, *r_oldviewleaf; extern mleaf_t *r_viewleaf, *r_oldviewleaf;
extern int d_lightstylevalue[256]; // 8.8 fraction of base light value extern int d_lightstylevalue[256]; // 8.8 fraction of base light value
extern cvar_t r_norefresh; extern convar r_norefresh;
extern cvar_t r_drawentities; extern convar r_drawentities;
extern cvar_t r_drawworld; extern convar r_drawworld;
extern cvar_t r_drawviewmodel; extern convar r_drawviewmodel;
extern cvar_t r_speeds; extern convar r_speeds;
extern cvar_t r_pos; extern convar r_pos;
extern cvar_t r_waterwarp; extern convar r_waterwarp;
extern cvar_t r_fullbright; extern convar r_fullbright;
extern cvar_t r_lightmap; extern convar r_lightmap;
extern cvar_t r_lightmapwide; extern convar r_lightmapwide;
extern cvar_t r_shadows; extern convar r_shadows;
extern cvar_t r_wateralpha; extern convar r_wateralpha;
extern cvar_t r_lavaalpha; extern convar r_lavaalpha;
extern cvar_t r_telealpha; extern convar r_telealpha;
extern cvar_t r_slimealpha; extern convar r_slimealpha;
extern cvar_t r_litwater; extern convar r_litwater;
extern cvar_t r_dynamic; extern convar r_dynamic;
extern cvar_t r_novis; extern convar r_novis;
extern cvar_t r_scale; extern convar r_scale;
extern cvar_t gl_clear; extern convar gl_clear;
extern cvar_t gl_cull; extern convar gl_cull;
extern cvar_t gl_smoothmodels; extern convar gl_smoothmodels;
extern cvar_t gl_affinemodels; extern convar gl_affinemodels;
extern cvar_t gl_polyblend; extern convar gl_polyblend;
extern cvar_t gl_flashblend; extern convar gl_flashblend;
extern cvar_t gl_nocolors; extern convar gl_nocolors;
extern cvar_t gl_finish; extern convar gl_finish;
extern cvar_t gl_playermip; extern convar gl_playermip;
extern cvar_t gl_subdivide_size; extern convar gl_subdivide_size;
extern float load_subdivide_size; //johnfitz -- remember what subdivide_size value was when this map was loaded extern float load_subdivide_size; //johnfitz -- remember what subdivide_size value was when this map was loaded
extern int gl_stencilbits; extern int gl_stencilbits;
@@ -281,7 +281,7 @@ extern int rs_brushpolys, rs_aliaspolys, rs_skypolys;
extern int rs_dynamiclightmaps, rs_brushpasses, rs_aliaspasses, rs_skypasses; extern int rs_dynamiclightmaps, rs_brushpasses, rs_aliaspasses, rs_skypasses;
//johnfitz -- track developer statistics that vary every frame //johnfitz -- track developer statistics that vary every frame
extern cvar_t devstats; extern convar devstats;
typedef struct { typedef struct {
int packetsize; int packetsize;
int edicts; int edicts;
+60 -60
View File
@@ -57,35 +57,35 @@ jmp_buf host_abortserver;
byte *host_colormap; byte *host_colormap;
cvar_t host_framerate = {"host_framerate","0",CVAR_NONE}; // set for slow motion convar host_framerate = {"host_framerate","0"}; // set for slow motion
cvar_t host_speeds = {"host_speeds","0",CVAR_NONE}; // set for running times convar host_speeds = {"host_speeds","0"}; // set for running times
cvar_t host_maxfps = {"host_maxfps", "72", CVAR_ARCHIVE}; //johnfitz convar host_maxfps = {"host_maxfps", "72", {.archive = true}}; //johnfitz
cvar_t host_timescale = {"host_timescale", "0", CVAR_NONE}; //johnfitz convar host_timescale = {"host_timescale", "0"}; //johnfitz
cvar_t max_edicts = {"max_edicts", "8192", CVAR_NONE}; //johnfitz //ericw -- changed from 2048 to 8192, removed CVAR_ARCHIVE convar max_edicts = {"max_edicts", "8192"}; //johnfitz //ericw -- changed from 2048 to 8192, removed CVAR_ARCHIVE
cvar_t sys_ticrate = {"sys_ticrate","0.05",CVAR_NONE}; // dedicated server convar sys_ticrate = {"sys_ticrate","0.05"}; // dedicated server
cvar_t serverprofile = {"serverprofile","0",CVAR_NONE}; convar serverprofile = {"serverprofile","0"};
cvar_t fraglimit = {"fraglimit","0",CVAR_NOTIFY|CVAR_SERVERINFO}; convar fraglimit = {"fraglimit","0",{.notify = true, .server_info = true}};
cvar_t timelimit = {"timelimit","0",CVAR_NOTIFY|CVAR_SERVERINFO}; convar timelimit = {"timelimit","0", {.notify = true, .server_info = true}};
cvar_t teamplay = {"teamplay","0",CVAR_NOTIFY|CVAR_SERVERINFO}; convar teamplay = {"teamplay","0",{.notify = true, .server_info = true}};
cvar_t samelevel = {"samelevel","0",CVAR_NONE}; convar samelevel = {"samelevel","0"};
cvar_t noexit = {"noexit","0",CVAR_NOTIFY|CVAR_SERVERINFO}; convar noexit = {"noexit","0",{.notify = true, .server_info = true}};
cvar_t skill = {"skill","1",CVAR_NONE}; // 0 - 3 convar skill = {"skill","1"}; // 0 - 3
cvar_t deathmatch = {"deathmatch","0",CVAR_NONE}; // 0, 1, or 2 convar deathmatch = {"deathmatch","0"}; // 0, 1, or 2
cvar_t coop = {"coop","0",CVAR_NONE}; // 0 or 1 convar coop = {"coop","0"}; // 0 or 1
cvar_t pausable = {"pausable","1",CVAR_NONE}; convar pausable = {"pausable","1"};
cvar_t developer = {"developer","0",CVAR_NONE}; convar developer = {"developer","0"};
cvar_t temp1 = {"temp1","0",CVAR_NONE}; convar temp1 = {"temp1","0"};
cvar_t devstats = {"devstats","0",CVAR_NONE}; //johnfitz -- track developer statistics that vary every frame convar devstats = {"devstats","0"}; //johnfitz -- track developer statistics that vary every frame
cvar_t campaign = {"campaign","0",CVAR_NONE}; // for the 2021 rerelease convar campaign = {"campaign","0"}; // for the 2021 rerelease
cvar_t horde = {"horde","0",CVAR_NONE}; // for the 2021 rerelease convar horde = {"horde","0"}; // for the 2021 rerelease
cvar_t sv_cheats = {"sv_cheats","0",CVAR_NONE}; // for the 2021 rerelease convar sv_cheats = {"sv_cheats","0"}; // for the 2021 rerelease
devstats_t dev_stats, dev_peakstats; devstats_t dev_stats, dev_peakstats;
overflowtimes_t dev_overflows; //this stores the last time overflow messages were displayed, not the last time overflows occured overflowtimes_t dev_overflows; //this stores the last time overflow messages were displayed, not the last time overflows occured
@@ -95,7 +95,7 @@ overflowtimes_t dev_overflows; //this stores the last time overflow messages wer
Max_Edicts_f -- johnfitz Max_Edicts_f -- johnfitz
================ ================
*/ */
static void Max_Edicts_f (cvar_t *var) static void Max_Edicts_f (convar *var)
{ {
//TODO: clamp it here? //TODO: clamp it here?
if (cls.state == ca_connected || sv.active) if (cls.state == ca_connected || sv.active)
@@ -107,7 +107,7 @@ static void Max_Edicts_f (cvar_t *var)
Max_Fps_f -- ericw Max_Fps_f -- ericw
================ ================
*/ */
static void Max_Fps_f (cvar_t *var) static void Max_Fps_f (convar *var)
{ {
if (var->value > 72) if (var->value > 72)
Con_Warning ("host_maxfps above 72 breaks physics.\n"); Con_Warning ("host_maxfps above 72 breaks physics.\n");
@@ -227,9 +227,9 @@ void Host_FindMaxClients (void)
svs.clients = (struct client_s *) Hunk_AllocName (svs.maxclientslimit*sizeof(client_t), "clients"); svs.clients = (struct client_s *) Hunk_AllocName (svs.maxclientslimit*sizeof(client_t), "clients");
if (svs.maxclients > 1) if (svs.maxclients > 1)
Cvar_SetQuick (&deathmatch, "1"); deathmatch.set("1");
else else
Cvar_SetQuick (&deathmatch, "0"); deathmatch.set("0");
} }
void Host_Version_f (void) void Host_Version_f (void)
@@ -240,10 +240,10 @@ void Host_Version_f (void)
} }
/* cvar callback functions : */ /* cvar callback functions : */
void Host_Callback_Notify (cvar_t *var) void Host_Callback_Notify (convar *var)
{ {
if (sv.active) if (sv.active)
SV_BroadcastPrintf ("\"%s\" changed to \"%s\"\n", var->name, var->string); SV_BroadcastPrintf ("\"%s\" changed to \"%s\"\n", var->name.c_str(), var->string);
} }
/* /*
@@ -253,45 +253,45 @@ Host_InitLocal
*/ */
void Host_InitLocal (void) void Host_InitLocal (void)
{ {
Cmd_AddCommand ("version", Host_Version_f); command::add ("version", Host_Version_f);
Host_InitCommands (); Host_InitCommands ();
Cvar_RegisterVariable (&host_framerate); host_framerate.inscribe();
Cvar_RegisterVariable (&host_speeds); host_speeds.inscribe();
Cvar_RegisterVariable (&host_maxfps); //johnfitz host_maxfps.inscribe(); //johnfitz
Cvar_SetCallback (&host_maxfps, Max_Fps_f); host_maxfps.set_callback(Max_Fps_f);
Cvar_RegisterVariable (&host_timescale); //johnfitz host_timescale.inscribe(); //johnfitz
Cvar_RegisterVariable (&max_edicts); //johnfitz max_edicts.inscribe(); //johnfitz
Cvar_SetCallback (&max_edicts, Max_Edicts_f); max_edicts.set_callback(Max_Edicts_f);
Cvar_RegisterVariable (&devstats); //johnfitz devstats.inscribe(); //johnfitz
Cvar_RegisterVariable (&sys_ticrate); sys_ticrate.inscribe();
Cvar_RegisterVariable (&sys_throttle); sys_throttle.inscribe();
Cvar_RegisterVariable (&serverprofile); serverprofile.inscribe();
Cvar_RegisterVariable (&fraglimit); fraglimit.inscribe();
Cvar_RegisterVariable (&timelimit); timelimit.inscribe();
Cvar_RegisterVariable (&teamplay); teamplay.inscribe();
Cvar_SetCallback (&fraglimit, Host_Callback_Notify); fraglimit.set_callback(Host_Callback_Notify);
Cvar_SetCallback (&timelimit, Host_Callback_Notify); timelimit.set_callback(Host_Callback_Notify);
Cvar_SetCallback (&teamplay, Host_Callback_Notify); teamplay.set_callback(Host_Callback_Notify);
Cvar_RegisterVariable (&samelevel); samelevel.inscribe();
Cvar_RegisterVariable (&noexit); noexit.inscribe();
Cvar_SetCallback (&noexit, Host_Callback_Notify); noexit.set_callback(Host_Callback_Notify);
Cvar_RegisterVariable (&skill); skill.inscribe();
Cvar_RegisterVariable (&developer); developer.inscribe();
Cvar_RegisterVariable (&coop); coop.inscribe();
Cvar_RegisterVariable (&deathmatch); deathmatch.inscribe();
Cvar_RegisterVariable (&campaign); campaign.inscribe();
Cvar_RegisterVariable (&horde); horde.inscribe();
Cvar_RegisterVariable (&sv_cheats); sv_cheats.inscribe();
Cvar_RegisterVariable (&pausable); pausable.inscribe();
Cvar_RegisterVariable (&temp1); temp1.inscribe();
Host_FindMaxClients (); Host_FindMaxClients ();
} }
@@ -661,7 +661,7 @@ void Host_ServerFrame (void)
if (active > 600 && dev_peakstats.edicts <= 600) if (active > 600 && dev_peakstats.edicts <= 600)
Con_DWarning ("%i edicts exceeds standard limit of 600 (max = %d).\n", active, sv.max_edicts); Con_DWarning ("%i edicts exceeds standard limit of 600 (max = %d).\n", active, sv.max_edicts);
dev_stats.edicts = active; dev_stats.edicts = active;
dev_peakstats.edicts = q_max(active, dev_peakstats.edicts); dev_peakstats.edicts = std::max(active, dev_peakstats.edicts);
} }
//johnfitz //johnfitz
@@ -832,7 +832,7 @@ void Host_Init (void)
Memory_Init (host_parms->membase, host_parms->memsize); Memory_Init (host_parms->membase, host_parms->memsize);
Cbuf_Init (); Cbuf_Init ();
Cmd_Init (); command::init ();
LOG_Init (host_parms); LOG_Init (host_parms);
Cvar_Init (); //johnfitz Cvar_Init (); //johnfitz
COM_Init (); COM_Init ();
+178 -172
View File
@@ -21,12 +21,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include <sstream>
#include "quakedef.hpp" #include "quakedef.hpp"
#ifndef _WIN32 #ifndef _WIN32
#include <dirent.h> #include <dirent.h>
#endif #endif
extern cvar_t pausable; extern convar pausable;
int current_skill; int current_skill;
@@ -425,11 +427,11 @@ static void Host_Status_f (void)
int hours = 0; int hours = 0;
int j; int j;
if (cmd_source == src_command) if (command::last_source == command::source::command)
{ {
if (!sv.active) if (!sv.active)
{ {
Cmd_ForwardToServer (); command::forward_to_server ();
return; return;
} }
print_fn = Con_Printf; print_fn = Con_Printf;
@@ -437,7 +439,7 @@ static void Host_Status_f (void)
else else
print_fn = SV_ClientPrintf; print_fn = SV_ClientPrintf;
print_fn ("host: %s\n", Cvar_VariableString ("hostname")); print_fn ("host: %s\n", convar::variable_string("hostname").value_or("").c_str());
print_fn ("version: %4.2f\n", VERSION); print_fn ("version: %4.2f\n", VERSION);
if (tcpipAvailable) if (tcpipAvailable)
print_fn ("tcp/ip: %s\n", my_tcpip_address); print_fn ("tcp/ip: %s\n", my_tcpip_address);
@@ -474,9 +476,9 @@ Sets client to godmode
*/ */
static void Host_God_f (void) static void Host_God_f (void)
{ {
if (cmd_source == src_command) if (command::last_source == command::source::command)
{ {
Cmd_ForwardToServer (); command::forward_to_server();
return; return;
} }
@@ -484,7 +486,7 @@ static void Host_God_f (void)
return; return;
//johnfitz -- allow user to explicitly set god mode to on or off //johnfitz -- allow user to explicitly set god mode to on or off
switch (Cmd_Argc()) switch (command::argc())
{ {
case 1: case 1:
sv_player->v.flags = (int)sv_player->v.flags ^ FL_GODMODE; sv_player->v.flags = (int)sv_player->v.flags ^ FL_GODMODE;
@@ -494,7 +496,7 @@ static void Host_God_f (void)
SV_ClientPrintf ("godmode ON\n"); SV_ClientPrintf ("godmode ON\n");
break; break;
case 2: case 2:
if (Q_atof(Cmd_Argv(1))) if (Q_atof(command::argv(1)->c_str()))
{ {
sv_player->v.flags = (int)sv_player->v.flags | FL_GODMODE; sv_player->v.flags = (int)sv_player->v.flags | FL_GODMODE;
SV_ClientPrintf ("godmode ON\n"); SV_ClientPrintf ("godmode ON\n");
@@ -513,9 +515,9 @@ static void Host_God_f (void)
} }
static void Host_Buddha_f (void) { static void Host_Buddha_f (void) {
if (cmd_source == src_command) if (command::last_source == command::source::command)
{ {
Cmd_ForwardToServer (); command::forward_to_server();
return; return;
} }
@@ -536,9 +538,9 @@ Host_Notarget_f
*/ */
static void Host_Notarget_f (void) static void Host_Notarget_f (void)
{ {
if (cmd_source == src_command) if (command::last_source == command::source::command)
{ {
Cmd_ForwardToServer (); command::forward_to_server();
return; return;
} }
@@ -546,7 +548,7 @@ static void Host_Notarget_f (void)
return; return;
//johnfitz -- allow user to explicitly set notarget to on or off //johnfitz -- allow user to explicitly set notarget to on or off
switch (Cmd_Argc()) switch (command::argc())
{ {
case 1: case 1:
sv_player->v.flags = (int)sv_player->v.flags ^ FL_NOTARGET; sv_player->v.flags = (int)sv_player->v.flags ^ FL_NOTARGET;
@@ -556,7 +558,7 @@ static void Host_Notarget_f (void)
SV_ClientPrintf ("notarget ON\n"); SV_ClientPrintf ("notarget ON\n");
break; break;
case 2: case 2:
if (Q_atof(Cmd_Argv(1))) if (Q_atof(command::argv(1)->c_str()))
{ {
sv_player->v.flags = (int)sv_player->v.flags | FL_NOTARGET; sv_player->v.flags = (int)sv_player->v.flags | FL_NOTARGET;
SV_ClientPrintf ("notarget ON\n"); SV_ClientPrintf ("notarget ON\n");
@@ -583,9 +585,9 @@ Host_Noclip_f
*/ */
static void Host_Noclip_f (void) static void Host_Noclip_f (void)
{ {
if (cmd_source == src_command) if (command::last_source == command::source::command)
{ {
Cmd_ForwardToServer (); command::forward_to_server();
return; return;
} }
@@ -593,7 +595,7 @@ static void Host_Noclip_f (void)
return; return;
//johnfitz -- allow user to explicitly set noclip to on or off //johnfitz -- allow user to explicitly set noclip to on or off
switch (Cmd_Argc()) switch (command::argc())
{ {
case 1: case 1:
if (sv_player->v.movetype != MOVETYPE_NOCLIP) if (sv_player->v.movetype != MOVETYPE_NOCLIP)
@@ -610,7 +612,7 @@ static void Host_Noclip_f (void)
} }
break; break;
case 2: case 2:
if (Q_atof(Cmd_Argv(1))) if (Q_atof(command::argv(1)->c_str()))
{ {
noclip_anglehack = true; noclip_anglehack = true;
sv_player->v.movetype = MOVETYPE_NOCLIP; sv_player->v.movetype = MOVETYPE_NOCLIP;
@@ -639,16 +641,15 @@ adapted from fteqw, originally by Alex Shadowalker
*/ */
static void Host_SetPos_f(void) static void Host_SetPos_f(void)
{ {
if (cmd_source == src_command) if (command::last_source == command::source::command)
{ {
Cmd_ForwardToServer (); command::forward_to_server();
return; return;
} }
if (pr_global_struct->deathmatch) if (pr_global_struct->deathmatch)
return; return;
if (Cmd_Argc() != 7 && Cmd_Argc() != 4) if (command::argc() != 7 && command::argc() != 4)
{ {
SV_ClientPrintf("usage:\n"); SV_ClientPrintf("usage:\n");
SV_ClientPrintf(" setpos <x> <y> <z>\n"); SV_ClientPrintf(" setpos <x> <y> <z>\n");
@@ -676,15 +677,15 @@ static void Host_SetPos_f(void)
sv_player->v.velocity[1] = 0; sv_player->v.velocity[1] = 0;
sv_player->v.velocity[2] = 0; sv_player->v.velocity[2] = 0;
sv_player->v.origin[0] = atof(Cmd_Argv(1)); sv_player->v.origin[0] = atof(command::argv(1)->c_str());
sv_player->v.origin[1] = atof(Cmd_Argv(2)); sv_player->v.origin[1] = atof(command::argv(2)->c_str());
sv_player->v.origin[2] = atof(Cmd_Argv(3)); sv_player->v.origin[2] = atof(command::argv(3)->c_str());
if (Cmd_Argc() == 7) if (command::argc() == 7)
{ {
sv_player->v.angles[0] = atof(Cmd_Argv(4)); sv_player->v.angles[0] = atof(command::argv(4)->c_str());
sv_player->v.angles[1] = atof(Cmd_Argv(5)); sv_player->v.angles[1] = atof(command::argv(5)->c_str());
sv_player->v.angles[2] = atof(Cmd_Argv(6)); sv_player->v.angles[2] = atof(command::argv(6)->c_str());
sv_player->v.fixangle = 1; sv_player->v.fixangle = 1;
} }
@@ -700,9 +701,9 @@ Sets client to flymode
*/ */
static void Host_Fly_f (void) static void Host_Fly_f (void)
{ {
if (cmd_source == src_command) if (command::last_source == command::source::command)
{ {
Cmd_ForwardToServer (); command::forward_to_server();
return; return;
} }
@@ -710,7 +711,7 @@ static void Host_Fly_f (void)
return; return;
//johnfitz -- allow user to explicitly set noclip to on or off //johnfitz -- allow user to explicitly set noclip to on or off
switch (Cmd_Argc()) switch (command::argc())
{ {
case 1: case 1:
if (sv_player->v.movetype != MOVETYPE_FLY) if (sv_player->v.movetype != MOVETYPE_FLY)
@@ -725,7 +726,7 @@ static void Host_Fly_f (void)
} }
break; break;
case 2: case 2:
if (Q_atof(Cmd_Argv(1))) if (Q_atof(command::argv(1)->c_str()))
{ {
sv_player->v.movetype = MOVETYPE_FLY; sv_player->v.movetype = MOVETYPE_FLY;
SV_ClientPrintf ("flymode ON\n"); SV_ClientPrintf ("flymode ON\n");
@@ -755,9 +756,9 @@ static void Host_Ping_f (void)
float total; float total;
client_t *client; client_t *client;
if (cmd_source == src_command) if (command::last_source == command::source::command)
{ {
Cmd_ForwardToServer (); command::forward_to_server();
return; return;
} }
@@ -796,7 +797,7 @@ static void Host_Map_f (void)
int i; int i;
char name[MAX_QPATH], *p; char name[MAX_QPATH], *p;
if (Cmd_Argc() < 2) //no map name given if (command::argc() < 2) //no map name given
{ {
if (cls.state == ca_dedicated) if (cls.state == ca_dedicated)
{ {
@@ -816,8 +817,10 @@ static void Host_Map_f (void)
return; return;
} }
if (cmd_source != src_command) if (command::last_source != command::source::command)
{
return; return;
}
cls.demonum = -1; // stop demo loop in case this fails cls.demonum = -1; // stop demo loop in case this fails
@@ -830,7 +833,7 @@ static void Host_Map_f (void)
SCR_BeginLoadingPlaque (); SCR_BeginLoadingPlaque ();
svs.serverflags = 0; // haven't completed an episode yet svs.serverflags = 0; // haven't completed an episode yet
q_strlcpy (name, Cmd_Argv(1), sizeof(name)); q_strlcpy (name, command::argv(1)->c_str(), sizeof(name));
// remove (any) trailing ".bsp" from mapname -- S.A. // remove (any) trailing ".bsp" from mapname -- S.A.
p = strstr(name, ".bsp"); p = strstr(name, ".bsp");
if (p && p[4] == '\0') if (p && p[4] == '\0')
@@ -842,13 +845,13 @@ static void Host_Map_f (void)
if (cls.state != ca_dedicated) if (cls.state != ca_dedicated)
{ {
memset (cls.spawnparms, 0, MAX_MAPSTRING); memset (cls.spawnparms, 0, MAX_MAPSTRING);
for (i = 2; i < Cmd_Argc(); i++) for (i = 2; i < command::argc(); i++)
{ {
q_strlcat (cls.spawnparms, Cmd_Argv(i), MAX_MAPSTRING); q_strlcat (cls.spawnparms, command::argv(i)->c_str(), MAX_MAPSTRING);
q_strlcat (cls.spawnparms, " ", MAX_MAPSTRING); q_strlcat (cls.spawnparms, " ", MAX_MAPSTRING);
} }
Cmd_ExecuteString ("connect local", src_command); command::execute_string ("connect local", command::source::command);
} }
} }
@@ -864,7 +867,7 @@ static void Host_Randmap_f (void)
int i, randlevel, numlevels; int i, randlevel, numlevels;
filelist_item_t *level; filelist_item_t *level;
if (cmd_source != src_command) if (command::last_source != command::source::command)
return; return;
for (level = extralevels, numlevels = 0; level; level = level->next) for (level = extralevels, numlevels = 0; level; level = level->next)
@@ -900,7 +903,7 @@ static void Host_Changelevel_f (void)
{ {
char level[MAX_QPATH]; char level[MAX_QPATH];
if (Cmd_Argc() != 2) if (command::argc() != 2)
{ {
Con_Printf ("changelevel <levelname> : continue game on a new level\n"); Con_Printf ("changelevel <levelname> : continue game on a new level\n");
return; return;
@@ -912,7 +915,7 @@ static void Host_Changelevel_f (void)
} }
//johnfitz -- check for client having map before anything else //johnfitz -- check for client having map before anything else
q_snprintf (level, sizeof(level), "maps/%s.bsp", Cmd_Argv(1)); q_snprintf (level, sizeof(level), "maps/%s.bsp", command::argv(1)->c_str());
if (!COM_FileExists(level, NULL)) if (!COM_FileExists(level, NULL))
Host_Error ("cannot find map %s", level); Host_Error ("cannot find map %s", level);
//johnfitz //johnfitz
@@ -921,7 +924,7 @@ static void Host_Changelevel_f (void)
IN_Activate(); // -- S.A. IN_Activate(); // -- S.A.
key_dest = key_game; // remove console or menu key_dest = key_game; // remove console or menu
SV_SaveSpawnparms (); SV_SaveSpawnparms ();
q_strlcpy (level, Cmd_Argv(1), sizeof(level)); q_strlcpy (level, command::argv(1)->c_str(), sizeof(level));
SV_SpawnServer (level); SV_SpawnServer (level);
// also issue an error if spawn failed -- O.S. // also issue an error if spawn failed -- O.S.
if (!sv.active) if (!sv.active)
@@ -942,7 +945,7 @@ static void Host_Restart_f (void)
if (cls.demoplayback || !sv.active) if (cls.demoplayback || !sv.active)
return; return;
if (cmd_source != src_command) if (command::last_source != command::source::command)
return; return;
q_strlcpy (mapname, sv.name, sizeof(mapname)); // mapname gets cleared in spawnserver q_strlcpy (mapname, sv.name, sizeof(mapname)); // mapname gets cleared in spawnserver
SV_SpawnServer (mapname); SV_SpawnServer (mapname);
@@ -984,7 +987,7 @@ static void Host_Connect_f (void)
CL_StopPlayback (); CL_StopPlayback ();
CL_Disconnect (); CL_Disconnect ();
} }
q_strlcpy (name, Cmd_Argv(1), sizeof(name)); q_strlcpy (name, command::argv(1).value_or("").c_str(), sizeof(name));
CL_EstablishConnection (name); CL_EstablishConnection (name);
Host_Reconnect_f (); Host_Reconnect_f ();
} }
@@ -1051,7 +1054,7 @@ static void Host_Savegame_f (void)
int i; int i;
char comment[SAVEGAME_COMMENT_LENGTH+1]; char comment[SAVEGAME_COMMENT_LENGTH+1];
if (cmd_source != src_command) if (command::last_source != command::source::command)
return; return;
if (!sv.active) if (!sv.active)
@@ -1072,13 +1075,13 @@ static void Host_Savegame_f (void)
return; return;
} }
if (Cmd_Argc() != 2) if (command::argc() != 2)
{ {
Con_Printf ("save <savename> : save a game\n"); Con_Printf ("save <savename> : save a game\n");
return; return;
} }
if (strstr(Cmd_Argv(1), "..")) if (strstr(command::argv(1)->c_str(), ".."))
{ {
Con_Printf ("Relative pathnames are not allowed.\n"); Con_Printf ("Relative pathnames are not allowed.\n");
return; return;
@@ -1093,7 +1096,7 @@ static void Host_Savegame_f (void)
} }
} }
q_snprintf (name, sizeof(name), "%s/%s", com_gamedir, Cmd_Argv(1)); q_snprintf (name, sizeof(name), "%s/%s", com_gamedir, command::argv(1)->c_str());
COM_AddExtension (name, ".sav", sizeof(name)); COM_AddExtension (name, ".sav", sizeof(name));
Con_Printf ("Saving game to %s...\n", name); Con_Printf ("Saving game to %s...\n", name);
@@ -1143,24 +1146,22 @@ static void Host_Loadgame_f (void)
char name[MAX_OSPATH]; char name[MAX_OSPATH];
char mapname[MAX_QPATH]; char mapname[MAX_QPATH];
float time, tfloat;
const char *data;
int i; int i;
edict_t *ent; edict_t *ent;
int entnum; int entnum;
int version; int version;
float spawn_parms[NUM_SPAWN_PARMS]; float spawn_parms[NUM_SPAWN_PARMS];
if (cmd_source != src_command) if (command::last_source != command::source::command)
return; return;
if (Cmd_Argc() != 2) if (command::argc() != 2)
{ {
Con_Printf ("load <savename> : load a game\n"); Con_Printf ("load <savename> : load a game\n");
return; return;
} }
if (strstr(Cmd_Argv(1), "..")) if (strstr(command::argv(1)->c_str(), ".."))
{ {
Con_Printf ("Relative pathnames are not allowed.\n"); Con_Printf ("Relative pathnames are not allowed.\n");
return; return;
@@ -1168,7 +1169,7 @@ static void Host_Loadgame_f (void)
cls.demonum = -1; // stop demo loop in case this fails cls.demonum = -1; // stop demo loop in case this fails
q_snprintf (name, sizeof(name), "%s/%s", com_gamedir, Cmd_Argv(1)); q_snprintf (name, sizeof(name), "%s/%s", com_gamedir, command::argv(1)->c_str());
COM_AddExtension (name, ".sav", sizeof(name)); COM_AddExtension (name, ".sav", sizeof(name));
// we can't call SCR_BeginLoadingPlaque, because too much stack space has // we can't call SCR_BeginLoadingPlaque, because too much stack space has
@@ -1188,8 +1189,8 @@ static void Host_Loadgame_f (void)
return; return;
} }
data = start; std::istringstream ss{start};
data = COM_ParseIntNewline (data, &version); version = common::parse_int_newline(ss);
if (version != SAVEGAME_VERSION) if (version != SAVEGAME_VERSION)
{ {
free (start); free (start);
@@ -1197,17 +1198,17 @@ static void Host_Loadgame_f (void)
Host_Error ("Savegame is version %i, not %i", version, SAVEGAME_VERSION); Host_Error ("Savegame is version %i, not %i", version, SAVEGAME_VERSION);
return; return;
} }
data = COM_ParseStringNewline (data); auto strr = common::parse_string_newline (ss);
for (i = 0; i < NUM_SPAWN_PARMS; i++) for (i = 0; i < NUM_SPAWN_PARMS; i++)
data = COM_ParseFloatNewline (data, &spawn_parms[i]); spawn_parms[i] = common::parse_float_newline(ss);
// this silliness is so we can load 1.06 save files, which have float skill values // this silliness is so we can load 1.06 save files, which have float skill values
data = COM_ParseFloatNewline(data, &tfloat); const float tfloat = common::parse_float_newline(ss);
current_skill = (int)(tfloat + 0.1); current_skill = (int)(tfloat + 0.1);
Cvar_SetValue ("skill", (float)current_skill); convar::set_value ("skill", (float)current_skill);
data = COM_ParseStringNewline (data); strr = common::parse_string_newline(ss);
q_strlcpy (mapname, com_token, sizeof(mapname)); q_strlcpy (mapname, strr.c_str(), sizeof(mapname));
data = COM_ParseFloatNewline (data, &time); const float time = common::parse_float_newline(ss);
CL_Disconnect_f (); CL_Disconnect_f ();
@@ -1227,25 +1228,25 @@ static void Host_Loadgame_f (void)
// load the light styles // load the light styles
for (i = 0; i < MAX_LIGHTSTYLES; i++) for (i = 0; i < MAX_LIGHTSTYLES; i++)
{ {
data = COM_ParseStringNewline (data); strr = common::parse_string_newline(ss);
sv.lightstyles[i] = (const char *)Hunk_Strdup (com_token, "lightstyles"); sv.lightstyles[i] = (const char *)Hunk_Strdup (strr.c_str(), "lightstyles");
} }
// load the edicts out of the savegame file // load the edicts out of the savegame file
entnum = -1; // -1 is the globals entnum = -1; // -1 is the globals
while (*data) while (!ss.eof())
{ {
data = COM_Parse (data); auto token = common::parse_token(ss);
if (!com_token[0]) if (!token.has_value())
break; // end of file break; // end of file
if (strcmp(com_token,"{")) if (token->front() != '{')
{ {
Host_Error ("First token isn't a brace"); Host_Error ("First token isn't a brace");
} }
if (entnum == -1) if (entnum == -1)
{ // parse the global vars { // parse the global vars
data = ED_ParseGlobals (data); ED_ParseGlobals (ss);
} }
else else
{ // parse an edict { // parse an edict
@@ -1258,7 +1259,7 @@ static void Host_Loadgame_f (void)
memset (ent, 0, pr_edict_size); memset (ent, 0, pr_edict_size);
ent->baseline.scale = ENTSCALE_DEFAULT; ent->baseline.scale = ENTSCALE_DEFAULT;
} }
data = ED_ParseEdict (data, ent); ED_ParseEdict (ss, ent);
// link it into the bsp tree // link it into the bsp tree
if (!ent->free) if (!ent->free)
@@ -1302,24 +1303,24 @@ static void Host_Name_f (void)
{ {
char newName[32]; char newName[32];
if (Cmd_Argc () == 1) if (command::argc () == 1)
{ {
Con_Printf ("\"name\" is \"%s\"\n", cl_name.string); Con_Printf ("\"name\" is \"%s\"\n", cl_name.string);
return; return;
} }
if (Cmd_Argc () == 2) if (command::argc () == 2)
q_strlcpy(newName, Cmd_Argv(1), sizeof(newName)); q_strlcpy(newName, command::argv(1)->c_str(), sizeof(newName));
else else
q_strlcpy(newName, Cmd_Args(), sizeof(newName)); q_strlcpy(newName, command::args().c_str(), sizeof(newName));
newName[15] = 0; // client_t structure actually says name[32]. newName[15] = 0; // client_t structure actually says name[32].
if (cmd_source == src_command) if (command::last_source == command::source::command)
{ {
if (Q_strcmp(cl_name.string, newName) == 0) if (Q_strcmp(cl_name.string, newName) == 0)
return; return;
Cvar_Set ("_cl_name", newName); convar::set("_cl_name", newName);
if (cls.state == ca_connected) if (cls.state == ca_connected)
Cmd_ForwardToServer (); command::forward_to_server ();
return; return;
} }
@@ -1342,28 +1343,28 @@ static void Host_Say(qboolean teamonly)
int j; int j;
client_t *client; client_t *client;
client_t *save; client_t *save;
const char *p;
char text[MAXCMDLINE], *p2; char text[MAXCMDLINE], *p2;
qboolean quoted; qboolean quoted;
qboolean fromServer = false; qboolean fromServer = false;
if (cmd_source == src_command) if (command::last_source == command::source::command)
{ {
if (cls.state != ca_dedicated) if (cls.state != ca_dedicated)
{ {
Cmd_ForwardToServer (); command::forward_to_server ();
return; return;
} }
fromServer = true; fromServer = true;
teamonly = false; teamonly = false;
} }
if (Cmd_Argc () < 2) if (command::argc () < 2)
return; return;
save = host_client; save = host_client;
p = Cmd_Args(); auto args = command::args();
auto p = args.c_str();
// remove quotes if present // remove quotes if present
quoted = false; quoted = false;
if (*p == '\"') if (*p == '\"')
@@ -1433,16 +1434,17 @@ static void Host_Tell_f(void)
char text[MAXCMDLINE], *p2; char text[MAXCMDLINE], *p2;
qboolean quoted; qboolean quoted;
if (cmd_source == src_command) if (command::last_source == command::source::command)
{ {
Cmd_ForwardToServer (); command::forward_to_server();
return; return;
} }
if (Cmd_Argc () < 3) if (command::argc () < 3)
return; return;
p = Cmd_Args(); auto args = command::args();
p = args.c_str();
// remove quotes if present // remove quotes if present
quoted = false; quoted = false;
if (*p == '\"') if (*p == '\"')
@@ -1479,7 +1481,7 @@ static void Host_Tell_f(void)
{ {
if (!client->active || !client->spawned) if (!client->active || !client->spawned)
continue; continue;
if (q_strcasecmp(client->name, Cmd_Argv(1))) if (q_strcasecmp(client->name, command::argv(1)->c_str()))
continue; continue;
host_client = client; host_client = client;
SV_ClientPrintf("%s", text); SV_ClientPrintf("%s", text);
@@ -1498,19 +1500,19 @@ static void Host_Color_f(void)
int top, bottom; int top, bottom;
int playercolor; int playercolor;
if (Cmd_Argc() == 1) if (command::argc() == 1)
{ {
Con_Printf ("\"color\" is \"%i %i\"\n", ((int)cl_color.value) >> 4, ((int)cl_color.value) & 0x0f); Con_Printf ("\"color\" is \"%i %i\"\n", ((int)cl_color.value) >> 4, ((int)cl_color.value) & 0x0f);
Con_Printf ("color <0-13> [0-13]\n"); Con_Printf ("color <0-13> [0-13]\n");
return; return;
} }
if (Cmd_Argc() == 2) if (command::argc() == 2)
top = bottom = atoi(Cmd_Argv(1)); top = bottom = atoi(command::argv(1)->c_str());
else else
{ {
top = atoi(Cmd_Argv(1)); top = atoi(command::argv(1)->c_str());
bottom = atoi(Cmd_Argv(2)); bottom = atoi(command::argv(2)->c_str());
} }
top &= 15; top &= 15;
@@ -1522,11 +1524,11 @@ static void Host_Color_f(void)
playercolor = top*16 + bottom; playercolor = top*16 + bottom;
if (cmd_source == src_command) if (command::last_source == command::source::command)
{ {
Cvar_SetValue ("_cl_color", playercolor); convar::set_value ("_cl_color", playercolor);
if (cls.state == ca_connected) if (cls.state == ca_connected)
Cmd_ForwardToServer (); command::forward_to_server ();
return; return;
} }
@@ -1546,9 +1548,9 @@ Host_Kill_f
*/ */
static void Host_Kill_f (void) static void Host_Kill_f (void)
{ {
if (cmd_source == src_command) if (command::last_source == command::source::command)
{ {
Cmd_ForwardToServer (); command::forward_to_server();
return; return;
} }
@@ -1578,9 +1580,9 @@ static void Host_Pause_f (void)
return; return;
} }
if (cmd_source == src_command) if (command::last_source == command::source::command)
{ {
Cmd_ForwardToServer (); command::forward_to_server();
return; return;
} }
if (!pausable.value) if (!pausable.value)
@@ -1613,7 +1615,7 @@ Host_PreSpawn_f
*/ */
static void Host_PreSpawn_f (void) static void Host_PreSpawn_f (void)
{ {
if (cmd_source == src_command) if (command::last_source == command::source::command)
{ {
Con_Printf ("prespawn is not valid from the console\n"); Con_Printf ("prespawn is not valid from the console\n");
return; return;
@@ -1640,7 +1642,7 @@ static void Host_Spawn_f (void)
client_t *client; client_t *client;
edict_t *ent; edict_t *ent;
if (cmd_source == src_command) if (command::last_source == command::source::command)
{ {
Con_Printf ("spawn is not valid from the console\n"); Con_Printf ("spawn is not valid from the console\n");
return; return;
@@ -1755,7 +1757,7 @@ Host_Begin_f
*/ */
static void Host_Begin_f (void) static void Host_Begin_f (void)
{ {
if (cmd_source == src_command) if (command::last_source == command::source::command)
{ {
Con_Printf ("begin is not valid from the console\n"); Con_Printf ("begin is not valid from the console\n");
return; return;
@@ -1776,16 +1778,15 @@ Kicks a user off of the server
static void Host_Kick_f (void) static void Host_Kick_f (void)
{ {
const char *who; const char *who;
const char *message = NULL;
client_t *save; client_t *save;
int i; int i;
qboolean byNumber = false; qboolean byNumber = false;
if (cmd_source == src_command) if (command::last_source == command::source::command)
{ {
if (!sv.active) if (!sv.active)
{ {
Cmd_ForwardToServer (); command::forward_to_server ();
return; return;
} }
} }
@@ -1794,9 +1795,9 @@ static void Host_Kick_f (void)
save = host_client; save = host_client;
if (Cmd_Argc() > 2 && Q_strcmp(Cmd_Argv(1), "#") == 0) if (command::argc() > 2 && Q_strcmp(command::argv(1)->c_str(), "#") == 0)
{ {
i = Q_atof(Cmd_Argv(2)) - 1; i = Q_atof(command::argv(2)->c_str()) - 1;
if (i < 0 || i >= svs.maxclients) if (i < 0 || i >= svs.maxclients)
return; return;
if (!svs.clients[i].active) if (!svs.clients[i].active)
@@ -1810,14 +1811,14 @@ static void Host_Kick_f (void)
{ {
if (!host_client->active) if (!host_client->active)
continue; continue;
if (q_strcasecmp(host_client->name, Cmd_Argv(1)) == 0) if (q_strcasecmp(host_client->name, command::argv(1).value_or("").c_str()) == 0)
break; break;
} }
} }
if (i < svs.maxclients) if (i < svs.maxclients)
{ {
if (cmd_source == src_command) if (command::last_source == command::source::command)
if (cls.state == ca_dedicated) if (cls.state == ca_dedicated)
who = "Console"; who = "Console";
else else
@@ -1829,21 +1830,25 @@ static void Host_Kick_f (void)
if (host_client == save) if (host_client == save)
return; return;
if (Cmd_Argc() > 2) std::string message{};
if (command::argc() > 2)
{ {
message = COM_Parse(Cmd_Args()); std::istringstream ss{command::args()};
auto token = common::parse_token(ss);
if (byNumber) if (byNumber)
{ {
message++; // skip the # ss.get();
while (*message == ' ') // skip white space while (ss.peek() == ' ') // skip white space
message++; ss.get();
message += strlen(Cmd_Argv(2)); // skip the number ss.seekg(command::argv(2)->length(), std::ios_base::seekdir::_S_cur); // skip the number
} }
while (*message && *message == ' ') while (!ss.eof() && ss.peek() == ' ')
message++; ss.get();
message += ss.str().substr(ss.tellg());
} }
if (message) if (!message.empty())
SV_ClientPrintf ("Kicked by %s: %s\n", who, message); SV_ClientPrintf ("Kicked by %s: %s\n", who, message.c_str());
else else
SV_ClientPrintf ("Kicked by %s\n", who); SV_ClientPrintf ("Kicked by %s\n", who);
SV_DropClient (false); SV_DropClient (false);
@@ -1871,17 +1876,18 @@ static void Host_Give_f (void)
int v; int v;
eval_t *val; eval_t *val;
if (cmd_source == src_command) if (command::last_source == command::source::command)
{ {
Cmd_ForwardToServer (); command::forward_to_server();
return; return;
} }
if (pr_global_struct->deathmatch) if (pr_global_struct->deathmatch)
return; return;
t = Cmd_Argv(1); auto arg1 = command::argv(1).value_or("");
v = atoi (Cmd_Argv(2)); t = arg1.c_str();
v = atoi (command::argv(2).value_or("").c_str());
switch (t[0]) switch (t[0])
{ {
@@ -2119,10 +2125,10 @@ static void Host_Viewmodel_f (void)
if (!e) if (!e)
return; return;
m = Mod_ForName (Cmd_Argv(1), false); m = Mod_ForName (command::argv(1).value_or("").c_str(), false);
if (!m) if (!m)
{ {
Con_Printf ("Can't load %s\n", Cmd_Argv(1)); Con_Printf ("Can't load %s\n", command::argv(1).value_or("").c_str());
return; return;
} }
@@ -2146,7 +2152,7 @@ static void Host_Viewframe_f (void)
return; return;
m = cl.model_precache[(int)e->v.modelindex]; m = cl.model_precache[(int)e->v.modelindex];
f = atoi(Cmd_Argv(1)); f = atoi(command::argv(1).value_or("").c_str());
if (f >= m->numframes) if (f >= m->numframes)
f = m->numframes - 1; f = m->numframes - 1;
@@ -2231,7 +2237,7 @@ static void Host_Startdemos_f (void)
if (cls.state == ca_dedicated) if (cls.state == ca_dedicated)
return; return;
c = Cmd_Argc() - 1; c = command::argc() - 1;
if (c > MAX_DEMOS) if (c > MAX_DEMOS)
{ {
Con_Printf ("Max %i demos in demoloop\n", MAX_DEMOS); Con_Printf ("Max %i demos in demoloop\n", MAX_DEMOS);
@@ -2240,7 +2246,7 @@ static void Host_Startdemos_f (void)
Con_Printf ("%i demo(s) in loop\n", c); Con_Printf ("%i demo(s) in loop\n", c);
for (i = 1; i < c + 1; i++) for (i = 1; i < c + 1; i++)
q_strlcpy (cls.demos[i-1], Cmd_Argv(i), sizeof(cls.demos[0])); q_strlcpy (cls.demos[i-1], command::argv(i)->c_str(), sizeof(cls.demos[0]));
if (!sv.active && cls.demonum != -1 && !cls.demoplayback) if (!sv.active && cls.demonum != -1 && !cls.demoplayback)
{ {
@@ -2316,49 +2322,49 @@ Host_InitCommands
*/ */
void Host_InitCommands (void) void Host_InitCommands (void)
{ {
Cmd_AddCommand ("maps", Host_Maps_f); //johnfitz command::add ("maps", Host_Maps_f); //johnfitz
Cmd_AddCommand ("mods", Host_Mods_f); //johnfitz command::add ("mods", Host_Mods_f); //johnfitz
Cmd_AddCommand ("games", Host_Mods_f); // as an alias to "mods" -- S.A. / QuakeSpasm command::add ("games", Host_Mods_f); // as an alias to "mods" -- S.A. / QuakeSpasm
Cmd_AddCommand ("mapname", Host_Mapname_f); //johnfitz command::add ("mapname", Host_Mapname_f); //johnfitz
Cmd_AddCommand ("randmap", Host_Randmap_f); //ericw command::add ("randmap", Host_Randmap_f); //ericw
Cmd_AddCommand ("status", Host_Status_f); command::add ("status", Host_Status_f);
Cmd_AddCommand ("quit", Host_Quit_f); command::add ("quit", Host_Quit_f);
Cmd_AddCommand ("god", Host_God_f); command::add ("god", Host_God_f);
Cmd_AddCommand("buddha", Host_Buddha_f); command::add("buddha", Host_Buddha_f);
Cmd_AddCommand ("notarget", Host_Notarget_f); command::add ("notarget", Host_Notarget_f);
Cmd_AddCommand ("fly", Host_Fly_f); command::add ("fly", Host_Fly_f);
Cmd_AddCommand ("map", Host_Map_f); command::add ("map", Host_Map_f);
Cmd_AddCommand ("restart", Host_Restart_f); command::add ("restart", Host_Restart_f);
Cmd_AddCommand ("changelevel", Host_Changelevel_f); command::add ("changelevel", Host_Changelevel_f);
Cmd_AddCommand ("connect", Host_Connect_f); command::add ("connect", Host_Connect_f);
Cmd_AddCommand ("reconnect", Host_Reconnect_f); command::add ("reconnect", Host_Reconnect_f);
Cmd_AddCommand ("name", Host_Name_f); command::add ("name", Host_Name_f);
Cmd_AddCommand ("noclip", Host_Noclip_f); command::add ("noclip", Host_Noclip_f);
Cmd_AddCommand ("setpos", Host_SetPos_f); //QuakeSpasm command::add ("setpos", Host_SetPos_f); //QuakeSpasm
Cmd_AddCommand ("say", Host_Say_f); command::add ("say", Host_Say_f);
Cmd_AddCommand ("say_team", Host_Say_Team_f); command::add ("say_team", Host_Say_Team_f);
Cmd_AddCommand ("tell", Host_Tell_f); command::add ("tell", Host_Tell_f);
Cmd_AddCommand ("color", Host_Color_f); command::add ("color", Host_Color_f);
Cmd_AddCommand ("kill", Host_Kill_f); command::add ("kill", Host_Kill_f);
Cmd_AddCommand ("pause", Host_Pause_f); command::add ("pause", Host_Pause_f);
Cmd_AddCommand ("spawn", Host_Spawn_f); command::add ("spawn", Host_Spawn_f);
Cmd_AddCommand ("begin", Host_Begin_f); command::add ("begin", Host_Begin_f);
Cmd_AddCommand ("prespawn", Host_PreSpawn_f); command::add ("prespawn", Host_PreSpawn_f);
Cmd_AddCommand ("kick", Host_Kick_f); command::add ("kick", Host_Kick_f);
Cmd_AddCommand ("ping", Host_Ping_f); command::add ("ping", Host_Ping_f);
Cmd_AddCommand ("load", Host_Loadgame_f); command::add ("load", Host_Loadgame_f);
Cmd_AddCommand ("save", Host_Savegame_f); command::add ("save", Host_Savegame_f);
Cmd_AddCommand ("give", Host_Give_f); command::add ("give", Host_Give_f);
Cmd_AddCommand ("startdemos", Host_Startdemos_f); command::add ("startdemos", Host_Startdemos_f);
Cmd_AddCommand ("demos", Host_Demos_f); command::add ("demos", Host_Demos_f);
Cmd_AddCommand ("stopdemo", Host_Stopdemo_f); command::add ("stopdemo", Host_Stopdemo_f);
Cmd_AddCommand ("viewmodel", Host_Viewmodel_f); command::add ("viewmodel", Host_Viewmodel_f);
Cmd_AddCommand ("viewframe", Host_Viewframe_f); command::add ("viewframe", Host_Viewframe_f);
Cmd_AddCommand ("viewnext", Host_Viewnext_f); command::add ("viewnext", Host_Viewnext_f);
Cmd_AddCommand ("viewprev", Host_Viewprev_f); command::add ("viewprev", Host_Viewprev_f);
} }
+152 -237
View File
@@ -35,7 +35,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static qboolean windowhasfocus = true; //just in case sdl fails to tell us... static qboolean windowhasfocus = true; //just in case sdl fails to tell us...
static qboolean textmode; static qboolean textmode;
static cvar_t in_debugkeys = {"in_debugkeys", "0", CVAR_NONE}; static convar in_debugkeys{"in_debugkeys", "0"};
#ifdef __APPLE__ #ifdef __APPLE__
/* Mouse acceleration needs to be disabled on OS X */ /* Mouse acceleration needs to be disabled on OS X */
@@ -50,18 +50,18 @@ static cvar_t in_debugkeys = {"in_debugkeys", "0", CVAR_NONE};
#endif #endif
// SDL2 Game Controller cvars // SDL2 Game Controller cvars
cvar_t joy_deadzone_look = { "joy_deadzone_look", "0.175", CVAR_ARCHIVE }; convar joy_deadzone_look{"joy_deadzone_look", "0.175", {.archive = true}};
cvar_t joy_deadzone_move = { "joy_deadzone_move", "0.175", CVAR_ARCHIVE }; convar joy_deadzone_move{"joy_deadzone_move", "0.175", {.archive = true}};
cvar_t joy_outer_threshold_look = { "joy_outer_threshold_look", "0.02", CVAR_ARCHIVE }; convar joy_outer_threshold_look{"joy_outer_threshold_look", "0.02", {.archive = true}};
cvar_t joy_outer_threshold_move = { "joy_outer_threshold_move", "0.02", CVAR_ARCHIVE }; convar joy_outer_threshold_move{"joy_outer_threshold_move", "0.02", {.archive = true}};
cvar_t joy_deadzone_trigger = { "joy_deadzone_trigger", "0.2", CVAR_ARCHIVE }; convar joy_deadzone_trigger{"joy_deadzone_trigger", "0.2", {.archive = true}};
cvar_t joy_sensitivity_yaw = { "joy_sensitivity_yaw", "240", CVAR_ARCHIVE }; convar joy_sensitivity_yaw{"joy_sensitivity_yaw", "240", {.archive = true}};
cvar_t joy_sensitivity_pitch = { "joy_sensitivity_pitch", "130", CVAR_ARCHIVE }; convar joy_sensitivity_pitch{"joy_sensitivity_pitch", "130", {.archive = true}};
cvar_t joy_invert = { "joy_invert", "0", CVAR_ARCHIVE }; convar joy_invert{"joy_invert", "0", {.archive = true}};
cvar_t joy_exponent = { "joy_exponent", "2", CVAR_ARCHIVE }; convar joy_exponent{"joy_exponent", "2", {.archive = true}};
cvar_t joy_exponent_move = { "joy_exponent_move", "2", CVAR_ARCHIVE }; convar joy_exponent_move{"joy_exponent_move", "2", {.archive = true}};
cvar_t joy_swapmovelook = { "joy_swapmovelook", "0", CVAR_ARCHIVE }; convar joy_swapmovelook{"joy_swapmovelook", "0", {.archive = true}};
cvar_t joy_enable = { "joy_enable", "1", CVAR_ARCHIVE }; convar joy_enable{"joy_enable", "1", {.archive = true}};
#if defined(USE_SDL2) #if defined(USE_SDL2)
static SDL_JoystickID joy_active_instaceid = -1; static SDL_JoystickID joy_active_instaceid = -1;
@@ -86,10 +86,8 @@ static int buttonremap[] =
/* total accumulated mouse movement since last frame */ /* total accumulated mouse movement since last frame */
static int total_dx, total_dy = 0; static int total_dx, total_dy = 0;
static int SDLCALL IN_FilterMouseEvents (const SDL_Event *event) static int SDLCALL IN_FilterMouseEvents(const SDL_Event *event) {
{ switch (event->type) {
switch (event->type)
{
case SDL_MOUSEMOTION: case SDL_MOUSEMOTION:
// case SDL_MOUSEBUTTONDOWN: // case SDL_MOUSEBUTTONDOWN:
// case SDL_MOUSEBUTTONUP: // case SDL_MOUSEBUTTONUP:
@@ -100,14 +98,12 @@ static int SDLCALL IN_FilterMouseEvents (const SDL_Event *event)
} }
#if defined(USE_SDL2) #if defined(USE_SDL2)
static int SDLCALL IN_SDL2_FilterMouseEvents (void *userdata, SDL_Event *event) static int SDLCALL IN_SDL2_FilterMouseEvents(void *userdata, SDL_Event *event) {
{
return IN_FilterMouseEvents(event); return IN_FilterMouseEvents(event);
} }
#endif #endif
static void IN_BeginIgnoringMouseEvents(void) static void IN_BeginIgnoringMouseEvents(void) {
{
#if defined(USE_SDL2) #if defined(USE_SDL2)
SDL_EventFilter currentFilter = NULL; SDL_EventFilter currentFilter = NULL;
void *currentUserdata = NULL; void *currentUserdata = NULL;
@@ -121,8 +117,7 @@ static void IN_BeginIgnoringMouseEvents(void)
#endif #endif
} }
static void IN_EndIgnoringMouseEvents(void) static void IN_EndIgnoringMouseEvents(void) {
{
#if defined(USE_SDL2) #if defined(USE_SDL2)
SDL_EventFilter currentFilter; SDL_EventFilter currentFilter;
void *currentUserdata; void *currentUserdata;
@@ -135,11 +130,10 @@ static void IN_EndIgnoringMouseEvents(void)
} }
#ifdef MACOS_X_ACCELERATION_HACK #ifdef MACOS_X_ACCELERATION_HACK
static cvar_t in_disablemacosxmouseaccel = {"in_disablemacosxmouseaccel", "1", CVAR_ARCHIVE}; static convar in_disablemacosxmouseaccel = {"in_disablemacosxmouseaccel", "1", CVAR_ARCHIVE};
static double originalMouseSpeed = -1.0; static double originalMouseSpeed = -1.0;
static io_connect_t IN_GetIOHandle(void) static io_connect_t IN_GetIOHandle(void) {
{
io_connect_t iohandle = MACH_PORT_NULL; io_connect_t iohandle = MACH_PORT_NULL;
io_service_t iohidsystem = MACH_PORT_NULL; io_service_t iohidsystem = MACH_PORT_NULL;
mach_port_t masterport; mach_port_t masterport;
@@ -159,44 +153,34 @@ static io_connect_t IN_GetIOHandle(void)
return iohandle; return iohandle;
} }
static void IN_DisableOSXMouseAccel (void) static void IN_DisableOSXMouseAccel(void) {
{
io_connect_t mouseDev = IN_GetIOHandle(); io_connect_t mouseDev = IN_GetIOHandle();
if (mouseDev != 0) if (mouseDev != 0) {
{ if (IOHIDGetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), &originalMouseSpeed) ==
if (IOHIDGetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), &originalMouseSpeed) == kIOReturnSuccess) kIOReturnSuccess) {
{ if (IOHIDSetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), -1.0) != kIOReturnSuccess) {
if (IOHIDSetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), -1.0) != kIOReturnSuccess) convar::set("in_disablemacosxmouseaccel", "0");
{
Cvar_Set("in_disablemacosxmouseaccel", "0");
Con_Printf("WARNING: Could not disable mouse acceleration (failed at IOHIDSetAccelerationWithKey).\n"); Con_Printf("WARNING: Could not disable mouse acceleration (failed at IOHIDSetAccelerationWithKey).\n");
} }
} } else {
else convar::set("in_disablemacosxmouseaccel", "0");
{
Cvar_Set("in_disablemacosxmouseaccel", "0");
Con_Printf("WARNING: Could not disable mouse acceleration (failed at IOHIDGetAccelerationWithKey).\n"); Con_Printf("WARNING: Could not disable mouse acceleration (failed at IOHIDGetAccelerationWithKey).\n");
} }
IOServiceClose(mouseDev); IOServiceClose(mouseDev);
} } else {
else convar::set("in_disablemacosxmouseaccel", "0");
{
Cvar_Set("in_disablemacosxmouseaccel", "0");
Con_Printf("WARNING: Could not disable mouse acceleration (failed at IO_GetIOHandle).\n"); Con_Printf("WARNING: Could not disable mouse acceleration (failed at IO_GetIOHandle).\n");
} }
} }
static void IN_ReenableOSXMouseAccel (void) static void IN_ReenableOSXMouseAccel(void) {
{
io_connect_t mouseDev = IN_GetIOHandle(); io_connect_t mouseDev = IN_GetIOHandle();
if (mouseDev != 0) if (mouseDev != 0) {
{ if (IOHIDSetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), originalMouseSpeed) !=
if (IOHIDSetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), originalMouseSpeed) != kIOReturnSuccess) kIOReturnSuccess)
Con_Printf("WARNING: Could not re-enable mouse acceleration (failed at IOHIDSetAccelerationWithKey).\n"); Con_Printf("WARNING: Could not re-enable mouse acceleration (failed at IOHIDSetAccelerationWithKey).\n");
IOServiceClose(mouseDev); IOServiceClose(mouseDev);
} } else {
else
{
Con_Printf("WARNING: Could not re-enable mouse acceleration (failed at IO_GetIOHandle).\n"); Con_Printf("WARNING: Could not re-enable mouse acceleration (failed at IO_GetIOHandle).\n");
} }
originalMouseSpeed = -1; originalMouseSpeed = -1;
@@ -204,8 +188,7 @@ static void IN_ReenableOSXMouseAccel (void)
#endif /* MACOS_X_ACCELERATION_HACK */ #endif /* MACOS_X_ACCELERATION_HACK */
void IN_Activate (void) void IN_Activate(void) {
{
if (no_mouse) if (no_mouse)
return; return;
@@ -225,20 +208,17 @@ void IN_Activate (void)
} }
#endif #endif
if (SDL_SetRelativeMouseMode(SDL_TRUE) != 0) if (SDL_SetRelativeMouseMode(SDL_TRUE) != 0) {
{
Con_Printf("WARNING: SDL_SetRelativeMouseMode(SDL_TRUE) failed.\n"); Con_Printf("WARNING: SDL_SetRelativeMouseMode(SDL_TRUE) failed.\n");
} }
#else #else
if (SDL_WM_GrabInput(SDL_GRAB_QUERY) != SDL_GRAB_ON) if (SDL_WM_GrabInput(SDL_GRAB_QUERY) != SDL_GRAB_ON) {
{
SDL_WM_GrabInput(SDL_GRAB_ON); SDL_WM_GrabInput(SDL_GRAB_ON);
if (SDL_WM_GrabInput(SDL_GRAB_QUERY) != SDL_GRAB_ON) if (SDL_WM_GrabInput(SDL_GRAB_QUERY) != SDL_GRAB_ON)
Con_Printf("WARNING: SDL_WM_GrabInput(SDL_GRAB_ON) failed.\n"); Con_Printf("WARNING: SDL_WM_GrabInput(SDL_GRAB_ON) failed.\n");
} }
if (SDL_ShowCursor(SDL_QUERY) != SDL_DISABLE) if (SDL_ShowCursor(SDL_QUERY) != SDL_DISABLE) {
{
SDL_ShowCursor(SDL_DISABLE); SDL_ShowCursor(SDL_DISABLE);
if (SDL_ShowCursor(SDL_QUERY) != SDL_DISABLE) if (SDL_ShowCursor(SDL_QUERY) != SDL_DISABLE)
Con_Printf("WARNING: SDL_ShowCursor(SDL_DISABLE) failed.\n"); Con_Printf("WARNING: SDL_ShowCursor(SDL_DISABLE) failed.\n");
@@ -251,8 +231,7 @@ void IN_Activate (void)
total_dy = 0; total_dy = 0;
} }
void IN_Deactivate (qboolean free_cursor) void IN_Deactivate(qboolean free_cursor) {
{
if (no_mouse) if (no_mouse)
return; return;
@@ -261,20 +240,17 @@ void IN_Deactivate (qboolean free_cursor)
IN_ReenableOSXMouseAccel(); IN_ReenableOSXMouseAccel();
#endif #endif
if (free_cursor) if (free_cursor) {
{
#if defined(USE_SDL2) #if defined(USE_SDL2)
SDL_SetRelativeMouseMode(SDL_FALSE); SDL_SetRelativeMouseMode(SDL_FALSE);
#else #else
if (SDL_WM_GrabInput(SDL_GRAB_QUERY) != SDL_GRAB_OFF) if (SDL_WM_GrabInput(SDL_GRAB_QUERY) != SDL_GRAB_OFF) {
{
SDL_WM_GrabInput(SDL_GRAB_OFF); SDL_WM_GrabInput(SDL_GRAB_OFF);
if (SDL_WM_GrabInput(SDL_GRAB_QUERY) != SDL_GRAB_OFF) if (SDL_WM_GrabInput(SDL_GRAB_QUERY) != SDL_GRAB_OFF)
Con_Printf("WARNING: SDL_WM_GrabInput(SDL_GRAB_OFF) failed.\n"); Con_Printf("WARNING: SDL_WM_GrabInput(SDL_GRAB_OFF) failed.\n");
} }
if (SDL_ShowCursor(SDL_QUERY) != SDL_ENABLE) if (SDL_ShowCursor(SDL_QUERY) != SDL_ENABLE) {
{
SDL_ShowCursor(SDL_ENABLE); SDL_ShowCursor(SDL_ENABLE);
if (SDL_ShowCursor(SDL_QUERY) != SDL_ENABLE) if (SDL_ShowCursor(SDL_QUERY) != SDL_ENABLE)
Con_Printf("WARNING: SDL_ShowCursor(SDL_ENABLE) failed.\n"); Con_Printf("WARNING: SDL_ShowCursor(SDL_ENABLE) failed.\n");
@@ -286,8 +262,7 @@ void IN_Deactivate (qboolean free_cursor)
IN_BeginIgnoringMouseEvents(); IN_BeginIgnoringMouseEvents();
} }
void IN_StartupJoystick (void) void IN_StartupJoystick(void) {
{
#if defined(USE_SDL2) #if defined(USE_SDL2)
int i; int i;
int nummappings; int nummappings;
@@ -297,8 +272,7 @@ void IN_StartupJoystick (void)
if (COM_CheckParm("-nojoy")) if (COM_CheckParm("-nojoy"))
return; return;
if (SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) == -1 ) if (SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) == -1) {
{
Con_Warning("could not initialize SDL Game Controller\n"); Con_Warning("could not initialize SDL Game Controller\n");
return; return;
} }
@@ -310,51 +284,41 @@ void IN_StartupJoystick (void)
Con_Printf("%d mappings loaded from gamecontrollerdb.txt\n", nummappings); Con_Printf("%d mappings loaded from gamecontrollerdb.txt\n", nummappings);
// Also try host_parms->userdir // Also try host_parms->userdir
if (host_parms->userdir != host_parms->basedir) if (host_parms->userdir != host_parms->basedir) {
{
q_snprintf(controllerdb, sizeof(controllerdb), "%s/gamecontrollerdb.txt", host_parms->userdir); q_snprintf(controllerdb, sizeof(controllerdb), "%s/gamecontrollerdb.txt", host_parms->userdir);
nummappings = SDL_GameControllerAddMappingsFromFile(controllerdb); nummappings = SDL_GameControllerAddMappingsFromFile(controllerdb);
if (nummappings > 0) if (nummappings > 0)
Con_Printf("%d mappings loaded from gamecontrollerdb.txt\n", nummappings); Con_Printf("%d mappings loaded from gamecontrollerdb.txt\n", nummappings);
} }
for (i = 0; i < SDL_NumJoysticks(); i++) for (i = 0; i < SDL_NumJoysticks(); i++) {
{
const char *joyname = SDL_JoystickNameForIndex(i); const char *joyname = SDL_JoystickNameForIndex(i);
if ( SDL_IsGameController(i) ) if (SDL_IsGameController(i)) {
{
const char *controllername = SDL_GameControllerNameForIndex(i); const char *controllername = SDL_GameControllerNameForIndex(i);
gamecontroller = SDL_GameControllerOpen(i); gamecontroller = SDL_GameControllerOpen(i);
if (gamecontroller) if (gamecontroller) {
{
Con_Printf("detected controller: %s\n", controllername != NULL ? controllername : "NULL"); Con_Printf("detected controller: %s\n", controllername != NULL ? controllername : "NULL");
joy_active_instaceid = SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(gamecontroller)); joy_active_instaceid = SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(gamecontroller));
joy_active_controller = gamecontroller; joy_active_controller = gamecontroller;
break; break;
} } else {
else
{
Con_Warning("failed to open controller: %s\n", controllername != NULL ? controllername : "NULL"); Con_Warning("failed to open controller: %s\n", controllername != NULL ? controllername : "NULL");
} }
} } else {
else
{
Con_Warning("joystick missing controller mappings: %s\n", joyname != NULL ? joyname : "NULL"); Con_Warning("joystick missing controller mappings: %s\n", joyname != NULL ? joyname : "NULL");
} }
} }
#endif #endif
} }
void IN_ShutdownJoystick (void) void IN_ShutdownJoystick(void) {
{
#if defined(USE_SDL2) #if defined(USE_SDL2)
SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER); SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER);
#endif #endif
} }
void IN_Init (void) void IN_Init(void) {
{
textmode = Key_TextEntry(); textmode = Key_TextEntry();
#if !defined(USE_SDL2) #if !defined(USE_SDL2)
@@ -367,46 +331,43 @@ void IN_Init (void)
else else
SDL_StopTextInput(); SDL_StopTextInput();
#endif #endif
if (safemode || COM_CheckParm("-nomouse")) if (safemode || COM_CheckParm("-nomouse")) {
{
no_mouse = true; no_mouse = true;
/* discard all mouse events when input is deactivated */ /* discard all mouse events when input is deactivated */
IN_BeginIgnoringMouseEvents(); IN_BeginIgnoringMouseEvents();
} }
#ifdef MACOS_X_ACCELERATION_HACK #ifdef MACOS_X_ACCELERATION_HACK
Cvar_RegisterVariable(&in_disablemacosxmouseaccel); in_disablemacosxmouseaccel.inscribe();
#endif #endif
Cvar_RegisterVariable(&in_debugkeys); in_debugkeys.inscribe();
Cvar_RegisterVariable(&joy_sensitivity_yaw); joy_sensitivity_yaw.inscribe();
Cvar_RegisterVariable(&joy_sensitivity_pitch); joy_sensitivity_pitch.inscribe();
Cvar_RegisterVariable(&joy_deadzone_look); joy_deadzone_look.inscribe();
Cvar_RegisterVariable(&joy_deadzone_move); joy_deadzone_move.inscribe();
Cvar_RegisterVariable(&joy_outer_threshold_look); joy_outer_threshold_look.inscribe();
Cvar_RegisterVariable(&joy_outer_threshold_move); joy_outer_threshold_move.inscribe();
Cvar_RegisterVariable(&joy_deadzone_trigger); joy_deadzone_trigger.inscribe();
Cvar_RegisterVariable(&joy_invert); joy_invert.inscribe();
Cvar_RegisterVariable(&joy_exponent); joy_exponent.inscribe();
Cvar_RegisterVariable(&joy_exponent_move); joy_exponent_move.inscribe();
Cvar_RegisterVariable(&joy_swapmovelook); joy_swapmovelook.inscribe();
Cvar_RegisterVariable(&joy_enable); joy_enable.inscribe();
IN_Activate(); IN_Activate();
IN_StartupJoystick(); IN_StartupJoystick();
} }
void IN_Shutdown (void) void IN_Shutdown(void) {
{
IN_Deactivate(true); IN_Deactivate(true);
IN_ShutdownJoystick(); IN_ShutdownJoystick();
} }
extern cvar_t cl_maxpitch; /* johnfitz -- variable pitch clamping */ extern convar cl_maxpitch; /* johnfitz -- variable pitch clamping */
extern cvar_t cl_minpitch; /* johnfitz -- variable pitch clamping */ extern convar cl_minpitch; /* johnfitz -- variable pitch clamping */
void IN_MouseMotion(int dx, int dy) void IN_MouseMotion(int dx, int dy) {
{
if (!windowhasfocus) if (!windowhasfocus)
dx = dy = 0; //don't change view angles etc while unfocused. dx = dy = 0; //don't change view angles etc while unfocused.
total_dx += dx; total_dx += dx;
@@ -414,19 +375,16 @@ void IN_MouseMotion(int dx, int dy)
} }
#if defined(USE_SDL2) #if defined(USE_SDL2)
typedef struct joyaxis_s typedef struct joyaxis_s {
{
float x; float x;
float y; float y;
} joyaxis_t; } joyaxis_t;
typedef struct joy_buttonstate_s typedef struct joy_buttonstate_s {
{
qboolean buttondown[SDL_CONTROLLER_BUTTON_MAX]; qboolean buttondown[SDL_CONTROLLER_BUTTON_MAX];
} joybuttonstate_t; } joybuttonstate_t;
typedef struct axisstate_s typedef struct axisstate_s {
{
float axisvalue[SDL_CONTROLLER_AXIS_MAX]; // normalized to +-1 float axisvalue[SDL_CONTROLLER_AXIS_MAX]; // normalized to +-1
} joyaxisstate_t; } joyaxisstate_t;
@@ -448,8 +406,7 @@ IN_AxisMagnitude
Returns the vector length of the given joystick axis Returns the vector length of the given joystick axis
================ ================
*/ */
static vec_t IN_AxisMagnitude(joyaxis_t axis) static vec_t IN_AxisMagnitude(joyaxis_t axis) {
{
vec_t magnitude = sqrtf((axis.x * axis.x) + (axis.y * axis.y)); vec_t magnitude = sqrtf((axis.x * axis.x) + (axis.y * axis.y));
return magnitude; return magnitude;
} }
@@ -462,8 +419,7 @@ assumes axis values are in [-1, 1] and the vector magnitude has been clamped at
Raises the axis values to the given exponent, keeping signs. Raises the axis values to the given exponent, keeping signs.
================ ================
*/ */
static joyaxis_t IN_ApplyEasing(joyaxis_t axis, float exponent) static joyaxis_t IN_ApplyEasing(joyaxis_t axis, float exponent) {
{
joyaxis_t result = {0}; joyaxis_t result = {0};
vec_t eased_magnitude; vec_t eased_magnitude;
vec_t magnitude = IN_AxisMagnitude(axis); vec_t magnitude = IN_AxisMagnitude(axis);
@@ -493,14 +449,13 @@ from https://github.com/jeremiah-sypult/Quakespasm-Rift
and adapted from http://www.third-helix.com/2013/04/12/doing-thumbstick-dead-zones-right.html and adapted from http://www.third-helix.com/2013/04/12/doing-thumbstick-dead-zones-right.html
================ ================
*/ */
static joyaxis_t IN_ApplyDeadzone(joyaxis_t axis, float deadzone, float outer_threshold) static joyaxis_t IN_ApplyDeadzone(joyaxis_t axis, float deadzone, float outer_threshold) {
{
joyaxis_t result = {0}; joyaxis_t result = {0};
vec_t magnitude = IN_AxisMagnitude(axis); vec_t magnitude = IN_AxisMagnitude(axis);
if (magnitude > deadzone) { if (magnitude > deadzone) {
// rescale the magnitude so deadzone becomes 0, and 1-outer_threshold becomes 1 // rescale the magnitude so deadzone becomes 0, and 1-outer_threshold becomes 1
const vec_t new_magnitude = q_min(1.0, (magnitude - deadzone) / (1.0 - deadzone - outer_threshold)); const vec_t new_magnitude = std::min(1.0, (magnitude - deadzone) / (1.0 - deadzone - outer_threshold));
const vec_t scale = new_magnitude / magnitude; const vec_t scale = new_magnitude / magnitude;
result.x = axis.x * scale; result.x = axis.x * scale;
result.y = axis.y * scale; result.y = axis.y * scale;
@@ -514,10 +469,8 @@ static joyaxis_t IN_ApplyDeadzone(joyaxis_t axis, float deadzone, float outer_th
IN_KeyForControllerButton IN_KeyForControllerButton
================ ================
*/ */
static int IN_KeyForControllerButton(SDL_GameControllerButton button) static int IN_KeyForControllerButton(SDL_GameControllerButton button) {
{ switch (button) {
switch (button)
{
case SDL_CONTROLLER_BUTTON_A: return K_ABUTTON; case SDL_CONTROLLER_BUTTON_A: return K_ABUTTON;
case SDL_CONTROLLER_BUTTON_B: return K_BBUTTON; case SDL_CONTROLLER_BUTTON_B: return K_BBUTTON;
case SDL_CONTROLLER_BUTTON_X: return K_XBUTTON; case SDL_CONTROLLER_BUTTON_X: return K_XBUTTON;
@@ -546,31 +499,22 @@ and generates key repeats if the button is held down.
Adapted from DarkPlaces by lordhavoc Adapted from DarkPlaces by lordhavoc
================ ================
*/ */
static void IN_JoyKeyEvent(qboolean wasdown, qboolean isdown, int key, double *timer) static void IN_JoyKeyEvent(qboolean wasdown, qboolean isdown, int key, double *timer) {
{
// we can't use `realtime` for key repeats because it is not monotomic // we can't use `realtime` for key repeats because it is not monotomic
const double currenttime = Sys_DoubleTime(); const double currenttime = Sys_DoubleTime();
if (wasdown) if (wasdown) {
{ if (isdown) {
if (isdown) if (currenttime >= *timer) {
{
if (currenttime >= *timer)
{
*timer = currenttime + 0.1; *timer = currenttime + 0.1;
Key_Event(key, true); Key_Event(key, true);
} }
} } else {
else
{
*timer = 0; *timer = 0;
Key_Event(key, false); Key_Event(key, false);
} }
} } else {
else if (isdown) {
{
if (isdown)
{
*timer = currenttime + 0.5; *timer = currenttime + 0.5;
Key_Event(key, true); Key_Event(key, true);
} }
@@ -585,8 +529,7 @@ IN_Commands
Emit key events for game controller buttons, including emulated buttons for analog sticks/triggers Emit key events for game controller buttons, including emulated buttons for analog sticks/triggers
================ ================
*/ */
void IN_Commands (void) void IN_Commands(void) {
{
#if defined(USE_SDL2) #if defined(USE_SDL2)
joyaxisstate_t newaxisstate; joyaxisstate_t newaxisstate;
int i; int i;
@@ -600,34 +543,45 @@ void IN_Commands (void)
return; return;
// emit key events for controller buttons // emit key events for controller buttons
for (i = 0; i < SDL_CONTROLLER_BUTTON_MAX; i++) for (i = 0; i < SDL_CONTROLLER_BUTTON_MAX; i++) {
{
qboolean newstate = SDL_GameControllerGetButton(joy_active_controller, (SDL_GameControllerButton) i); qboolean newstate = SDL_GameControllerGetButton(joy_active_controller, (SDL_GameControllerButton) i);
qboolean oldstate = joy_buttonstate.buttondown[i]; qboolean oldstate = joy_buttonstate.buttondown[i];
joy_buttonstate.buttondown[i] = newstate; joy_buttonstate.buttondown[i] = newstate;
// NOTE: This can cause a reentrant call of IN_Commands, via SCR_ModalMessage when confirming a new game. // NOTE: This can cause a reentrant call of IN_Commands, via SCR_ModalMessage when confirming a new game.
IN_JoyKeyEvent(oldstate, newstate, IN_KeyForControllerButton((SDL_GameControllerButton)i), &joy_buttontimer[i]); IN_JoyKeyEvent(oldstate, newstate, IN_KeyForControllerButton((SDL_GameControllerButton) i),
&joy_buttontimer[i]);
} }
for (i = 0; i < SDL_CONTROLLER_AXIS_MAX; i++) for (i = 0; i < SDL_CONTROLLER_AXIS_MAX; i++) {
{ newaxisstate.axisvalue[i] = SDL_GameControllerGetAxis(joy_active_controller, (SDL_GameControllerAxis) i) /
newaxisstate.axisvalue[i] = SDL_GameControllerGetAxis(joy_active_controller, (SDL_GameControllerAxis)i) / 32768.0f; 32768.0f;
} }
// emit emulated arrow keys so the analog sticks can be used in the menu // emit emulated arrow keys so the analog sticks can be used in the menu
if (key_dest != key_game) if (key_dest != key_game) {
{ IN_JoyKeyEvent(joy_axisstate.axisvalue[SDL_CONTROLLER_AXIS_LEFTX] < -stickthreshold,
IN_JoyKeyEvent(joy_axisstate.axisvalue[SDL_CONTROLLER_AXIS_LEFTX] < -stickthreshold, newaxisstate.axisvalue[SDL_CONTROLLER_AXIS_LEFTX] < -stickthreshold, K_LEFTARROW, &joy_emulatedkeytimer[0]); newaxisstate.axisvalue[SDL_CONTROLLER_AXIS_LEFTX] < -stickthreshold, K_LEFTARROW,
IN_JoyKeyEvent(joy_axisstate.axisvalue[SDL_CONTROLLER_AXIS_LEFTX] > stickthreshold, newaxisstate.axisvalue[SDL_CONTROLLER_AXIS_LEFTX] > stickthreshold, K_RIGHTARROW, &joy_emulatedkeytimer[1]); &joy_emulatedkeytimer[0]);
IN_JoyKeyEvent(joy_axisstate.axisvalue[SDL_CONTROLLER_AXIS_LEFTY] < -stickthreshold, newaxisstate.axisvalue[SDL_CONTROLLER_AXIS_LEFTY] < -stickthreshold, K_UPARROW, &joy_emulatedkeytimer[2]); IN_JoyKeyEvent(joy_axisstate.axisvalue[SDL_CONTROLLER_AXIS_LEFTX] > stickthreshold,
IN_JoyKeyEvent(joy_axisstate.axisvalue[SDL_CONTROLLER_AXIS_LEFTY] > stickthreshold, newaxisstate.axisvalue[SDL_CONTROLLER_AXIS_LEFTY] > stickthreshold, K_DOWNARROW, &joy_emulatedkeytimer[3]); newaxisstate.axisvalue[SDL_CONTROLLER_AXIS_LEFTX] > stickthreshold, K_RIGHTARROW,
&joy_emulatedkeytimer[1]);
IN_JoyKeyEvent(joy_axisstate.axisvalue[SDL_CONTROLLER_AXIS_LEFTY] < -stickthreshold,
newaxisstate.axisvalue[SDL_CONTROLLER_AXIS_LEFTY] < -stickthreshold, K_UPARROW,
&joy_emulatedkeytimer[2]);
IN_JoyKeyEvent(joy_axisstate.axisvalue[SDL_CONTROLLER_AXIS_LEFTY] > stickthreshold,
newaxisstate.axisvalue[SDL_CONTROLLER_AXIS_LEFTY] > stickthreshold, K_DOWNARROW,
&joy_emulatedkeytimer[3]);
} }
// emit emulated keys for the analog triggers // emit emulated keys for the analog triggers
IN_JoyKeyEvent(joy_axisstate.axisvalue[SDL_CONTROLLER_AXIS_TRIGGERLEFT] > triggerthreshold, newaxisstate.axisvalue[SDL_CONTROLLER_AXIS_TRIGGERLEFT] > triggerthreshold, K_LTRIGGER, &joy_emulatedkeytimer[4]); IN_JoyKeyEvent(joy_axisstate.axisvalue[SDL_CONTROLLER_AXIS_TRIGGERLEFT] > triggerthreshold,
IN_JoyKeyEvent(joy_axisstate.axisvalue[SDL_CONTROLLER_AXIS_TRIGGERRIGHT] > triggerthreshold, newaxisstate.axisvalue[SDL_CONTROLLER_AXIS_TRIGGERRIGHT] > triggerthreshold, K_RTRIGGER, &joy_emulatedkeytimer[5]); newaxisstate.axisvalue[SDL_CONTROLLER_AXIS_TRIGGERLEFT] > triggerthreshold, K_LTRIGGER,
&joy_emulatedkeytimer[4]);
IN_JoyKeyEvent(joy_axisstate.axisvalue[SDL_CONTROLLER_AXIS_TRIGGERRIGHT] > triggerthreshold,
newaxisstate.axisvalue[SDL_CONTROLLER_AXIS_TRIGGERRIGHT] > triggerthreshold, K_RTRIGGER,
&joy_emulatedkeytimer[5]);
joy_axisstate = newaxisstate; joy_axisstate = newaxisstate;
#endif #endif
@@ -638,13 +592,12 @@ void IN_Commands (void)
IN_JoyMove IN_JoyMove
================ ================
*/ */
void IN_JoyMove (usercmd_t *cmd) void IN_JoyMove(usercmd_t *cmd) {
{
#if defined(USE_SDL2) #if defined(USE_SDL2)
float speed; float speed;
joyaxis_t moveRaw, moveDeadzone, moveEased; joyaxis_t moveRaw, moveDeadzone, moveEased;
joyaxis_t lookRaw, lookDeadzone, lookEased; joyaxis_t lookRaw, lookDeadzone, lookEased;
extern cvar_t sv_maxspeed; extern convar sv_maxspeed;
if (!joy_enable.value) if (!joy_enable.value)
return; return;
@@ -660,8 +613,7 @@ void IN_JoyMove (usercmd_t *cmd)
lookRaw.x = joy_axisstate.axisvalue[SDL_CONTROLLER_AXIS_RIGHTX]; lookRaw.x = joy_axisstate.axisvalue[SDL_CONTROLLER_AXIS_RIGHTX];
lookRaw.y = joy_axisstate.axisvalue[SDL_CONTROLLER_AXIS_RIGHTY]; lookRaw.y = joy_axisstate.axisvalue[SDL_CONTROLLER_AXIS_RIGHTY];
if (joy_swapmovelook.value) if (joy_swapmovelook.value) {
{
joyaxis_t temp = moveRaw; joyaxis_t temp = moveRaw;
moveRaw = lookRaw; moveRaw = lookRaw;
lookRaw = temp; lookRaw = temp;
@@ -678,7 +630,7 @@ void IN_JoyMove (usercmd_t *cmd)
speed = sv_maxspeed.value; speed = sv_maxspeed.value;
else if (cl_forwardspeed.value >= sv_maxspeed.value) else if (cl_forwardspeed.value >= sv_maxspeed.value)
// not running, with always run = vanilla // not running, with always run = vanilla
speed = q_min(sv_maxspeed.value, cl_forwardspeed.value / cl_movespeedkey.value); speed = std::min(sv_maxspeed.value, cl_forwardspeed.value / cl_movespeedkey.value);
else else
// not running, with always run = off or quakespasm // not running, with always run = off or quakespasm
speed = cl_forwardspeed.value; speed = cl_forwardspeed.value;
@@ -687,7 +639,8 @@ void IN_JoyMove (usercmd_t *cmd)
cmd->forwardmove -= speed * moveEased.y; cmd->forwardmove -= speed * moveEased.y;
cl.viewangles[YAW] -= lookEased.x * joy_sensitivity_yaw.value * host_frametime; cl.viewangles[YAW] -= lookEased.x * joy_sensitivity_yaw.value * host_frametime;
cl.viewangles[PITCH] += lookEased.y * joy_sensitivity_pitch.value * (joy_invert.value ? -1.0 : 1.0) * host_frametime; cl.viewangles[PITCH] += lookEased.y * joy_sensitivity_pitch.value * (joy_invert.value ? -1.0 : 1.0) *
host_frametime;
if (lookEased.x != 0 || lookEased.y != 0) if (lookEased.x != 0 || lookEased.y != 0)
V_StopPitchDrift(); V_StopPitchDrift();
@@ -700,8 +653,7 @@ void IN_JoyMove (usercmd_t *cmd)
#endif #endif
} }
void IN_MouseMove(usercmd_t *cmd) void IN_MouseMove(usercmd_t *cmd) {
{
float dmx, dmy; float dmx, dmy;
dmx = total_dx * sensitivity.value; dmx = total_dx * sensitivity.value;
@@ -719,23 +671,19 @@ void IN_MouseMove(usercmd_t *cmd)
else else
cl.viewangles[YAW] -= m_yaw.value * dmx; cl.viewangles[YAW] -= m_yaw.value * dmx;
if (in_mlook.state & 1) if (in_mlook.state & 1) {
{
if (dmx || dmy) if (dmx || dmy)
V_StopPitchDrift(); V_StopPitchDrift();
} }
if ( (in_mlook.state & 1) && !(in_strafe.state & 1)) if ((in_mlook.state & 1) && !(in_strafe.state & 1)) {
{
cl.viewangles[PITCH] += m_pitch.value * dmy; cl.viewangles[PITCH] += m_pitch.value * dmy;
/* johnfitz -- variable pitch clamping */ /* johnfitz -- variable pitch clamping */
if (cl.viewangles[PITCH] > cl_maxpitch.value) if (cl.viewangles[PITCH] > cl_maxpitch.value)
cl.viewangles[PITCH] = cl_maxpitch.value; cl.viewangles[PITCH] = cl_maxpitch.value;
if (cl.viewangles[PITCH] < cl_minpitch.value) if (cl.viewangles[PITCH] < cl_minpitch.value)
cl.viewangles[PITCH] = cl_minpitch.value; cl.viewangles[PITCH] = cl_minpitch.value;
} } else {
else
{
if ((in_strafe.state & 1) && noclip_anglehack) if ((in_strafe.state & 1) && noclip_anglehack)
cmd->upmove -= m_forward.value * dmy; cmd->upmove -= m_forward.value * dmy;
else else
@@ -743,35 +691,28 @@ void IN_MouseMove(usercmd_t *cmd)
} }
} }
void IN_Move(usercmd_t *cmd) void IN_Move(usercmd_t *cmd) {
{
IN_JoyMove(cmd); IN_JoyMove(cmd);
IN_MouseMove(cmd); IN_MouseMove(cmd);
} }
void IN_ClearStates (void) void IN_ClearStates(void) {
{
} }
void IN_UpdateInputMode (void) void IN_UpdateInputMode(void) {
{
qboolean want_textmode = Key_TextEntry(); qboolean want_textmode = Key_TextEntry();
if (textmode != want_textmode) if (textmode != want_textmode) {
{
textmode = want_textmode; textmode = want_textmode;
#if !defined(USE_SDL2) #if !defined(USE_SDL2)
SDL_EnableUNICODE(textmode); SDL_EnableUNICODE(textmode);
if (in_debugkeys.value) if (in_debugkeys.value)
Con_Printf("SDL_EnableUNICODE %d time: %g\n", textmode, Sys_DoubleTime()); Con_Printf("SDL_EnableUNICODE %d time: %g\n", textmode, Sys_DoubleTime());
#else #else
if (textmode) if (textmode) {
{
SDL_StartTextInput(); SDL_StartTextInput();
if (in_debugkeys.value) if (in_debugkeys.value)
Con_Printf("SDL_StartTextInput time: %g\n", Sys_DoubleTime()); Con_Printf("SDL_StartTextInput time: %g\n", Sys_DoubleTime());
} } else {
else
{
SDL_StopTextInput(); SDL_StopTextInput();
if (in_debugkeys.value) if (in_debugkeys.value)
Con_Printf("SDL_StopTextInput time: %g\n", Sys_DoubleTime()); Con_Printf("SDL_StopTextInput time: %g\n", Sys_DoubleTime());
@@ -781,13 +722,11 @@ void IN_UpdateInputMode (void)
} }
#if !defined(USE_SDL2) #if !defined(USE_SDL2)
static inline int IN_SDL_KeysymToQuakeKey(SDLKey sym) static inline int IN_SDL_KeysymToQuakeKey(SDLKey sym) {
{
if (sym > SDLK_SPACE && sym < SDLK_DELETE) if (sym > SDLK_SPACE && sym < SDLK_DELETE)
return sym; return sym;
switch (sym) switch (sym) {
{
case SDLK_TAB: return K_TAB; case SDLK_TAB: return K_TAB;
case SDLK_RETURN: return K_ENTER; case SDLK_RETURN: return K_ENTER;
case SDLK_ESCAPE: return K_ESCAPE; case SDLK_ESCAPE: return K_ESCAPE;
@@ -857,10 +796,8 @@ static inline int IN_SDL_KeysymToQuakeKey(SDLKey sym)
#endif #endif
#if defined(USE_SDL2) #if defined(USE_SDL2)
static inline int IN_SDL2_ScancodeToQuakeKey(SDL_Scancode scancode) static inline int IN_SDL2_ScancodeToQuakeKey(SDL_Scancode scancode) {
{ switch (scancode) {
switch (scancode)
{
case SDL_SCANCODE_TAB: return K_TAB; case SDL_SCANCODE_TAB: return K_TAB;
case SDL_SCANCODE_RETURN: return K_ENTER; case SDL_SCANCODE_RETURN: return K_ENTER;
case SDL_SCANCODE_RETURN2: return K_ENTER; case SDL_SCANCODE_RETURN2: return K_ENTER;
@@ -980,14 +917,12 @@ static inline int IN_SDL2_ScancodeToQuakeKey(SDL_Scancode scancode)
#endif #endif
#if defined(USE_SDL2) #if defined(USE_SDL2)
static void IN_DebugTextEvent(SDL_Event *event) static void IN_DebugTextEvent(SDL_Event *event) {
{
Con_Printf("SDL_TEXTINPUT '%s' time: %g\n", event->text.text, Sys_DoubleTime()); Con_Printf("SDL_TEXTINPUT '%s' time: %g\n", event->text.text, Sys_DoubleTime());
} }
#endif #endif
static void IN_DebugKeyEvent(SDL_Event *event) static void IN_DebugKeyEvent(SDL_Event *event) {
{
const char *eventtype = (event->key.state == SDL_PRESSED) ? "SDL_KEYDOWN" : "SDL_KEYUP"; const char *eventtype = (event->key.state == SDL_PRESSED) ? "SDL_KEYDOWN" : "SDL_KEYUP";
#if defined(USE_SDL2) #if defined(USE_SDL2)
Con_Printf("%s scancode: '%s' keycode: '%s' time: %g\n", Con_Printf("%s scancode: '%s' keycode: '%s' time: %g\n",
@@ -1004,40 +939,30 @@ static void IN_DebugKeyEvent(SDL_Event *event)
#endif #endif
} }
void IN_SendKeyEvents (void) void IN_SendKeyEvents(void) {
{
SDL_Event event; SDL_Event event;
int key; int key;
qboolean down; qboolean down;
while (SDL_PollEvent(&event)) while (SDL_PollEvent(&event)) {
{ switch (event.type) {
switch (event.type)
{
#if defined(USE_SDL2) #if defined(USE_SDL2)
case SDL_WINDOWEVENT: case SDL_WINDOWEVENT:
if (event.window.event == SDL_WINDOWEVENT_FOCUS_GAINED) if (event.window.event == SDL_WINDOWEVENT_FOCUS_GAINED) {
{
windowhasfocus = true; windowhasfocus = true;
S_UnblockSound(); S_UnblockSound();
} } else if (event.window.event == SDL_WINDOWEVENT_FOCUS_LOST) {
else if (event.window.event == SDL_WINDOWEVENT_FOCUS_LOST)
{
windowhasfocus = false; windowhasfocus = false;
S_BlockSound(); S_BlockSound();
} }
break; break;
#else #else
case SDL_ACTIVEEVENT: case SDL_ACTIVEEVENT:
if (event.active.state & (SDL_APPINPUTFOCUS|SDL_APPACTIVE)) if (event.active.state & (SDL_APPINPUTFOCUS | SDL_APPACTIVE)) {
{ if (event.active.gain) {
if (event.active.gain)
{
windowhasfocus = true; windowhasfocus = true;
S_UnblockSound(); S_UnblockSound();
} } else {
else
{
windowhasfocus = false; windowhasfocus = false;
S_BlockSound(); S_BlockSound();
} }
@@ -1087,8 +1012,7 @@ void IN_SendKeyEvents (void)
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONUP:
if (event.button.button < 1 || if (event.button.button < 1 ||
event.button.button > Q_COUNTOF(buttonremap)) event.button.button > Q_COUNTOF(buttonremap)) {
{
Con_Printf("Ignored event for mouse button %d\n", Con_Printf("Ignored event for mouse button %d\n",
event.button.button); event.button.button);
break; break;
@@ -1098,13 +1022,10 @@ void IN_SendKeyEvents (void)
#if defined(USE_SDL2) #if defined(USE_SDL2)
case SDL_MOUSEWHEEL: case SDL_MOUSEWHEEL:
if (event.wheel.y > 0) if (event.wheel.y > 0) {
{
Key_Event(K_MWHEELUP, true); Key_Event(K_MWHEELUP, true);
Key_Event(K_MWHEELUP, false); Key_Event(K_MWHEELUP, false);
} } else if (event.wheel.y < 0) {
else if (event.wheel.y < 0)
{
Key_Event(K_MWHEELDOWN, true); Key_Event(K_MWHEELDOWN, true);
Key_Event(K_MWHEELDOWN, false); Key_Event(K_MWHEELDOWN, false);
} }
@@ -1117,29 +1038,24 @@ void IN_SendKeyEvents (void)
#if defined(USE_SDL2) #if defined(USE_SDL2)
case SDL_CONTROLLERDEVICEADDED: case SDL_CONTROLLERDEVICEADDED:
if (joy_active_instaceid == -1) if (joy_active_instaceid == -1) {
{
joy_active_controller = SDL_GameControllerOpen(event.cdevice.which); joy_active_controller = SDL_GameControllerOpen(event.cdevice.which);
if (joy_active_controller == NULL) if (joy_active_controller == NULL)
Con_DPrintf("Couldn't open game controller\n"); Con_DPrintf("Couldn't open game controller\n");
else else {
{
SDL_Joystick *joy; SDL_Joystick *joy;
joy = SDL_GameControllerGetJoystick(joy_active_controller); joy = SDL_GameControllerGetJoystick(joy_active_controller);
joy_active_instaceid = SDL_JoystickInstanceID(joy); joy_active_instaceid = SDL_JoystickInstanceID(joy);
} }
} } else
else
Con_DPrintf("Ignoring SDL_CONTROLLERDEVICEADDED\n"); Con_DPrintf("Ignoring SDL_CONTROLLERDEVICEADDED\n");
break; break;
case SDL_CONTROLLERDEVICEREMOVED: case SDL_CONTROLLERDEVICEREMOVED:
if (joy_active_instaceid != -1 && event.cdevice.which == joy_active_instaceid) if (joy_active_instaceid != -1 && event.cdevice.which == joy_active_instaceid) {
{
SDL_GameControllerClose(joy_active_controller); SDL_GameControllerClose(joy_active_controller);
joy_active_controller = NULL; joy_active_controller = NULL;
joy_active_instaceid = -1; joy_active_instaceid = -1;
} } else
else
Con_DPrintf("Ignoring SDL_CONTROLLERDEVICEREMOVED\n"); Con_DPrintf("Ignoring SDL_CONTROLLERDEVICEREMOVED\n");
break; break;
case SDL_CONTROLLERDEVICEREMAPPED: case SDL_CONTROLLERDEVICEREMAPPED:
@@ -1157,4 +1073,3 @@ void IN_SendKeyEvents (void)
} }
} }
} }
+14 -13
View File
@@ -628,6 +628,7 @@ void Key_SetBinding (int keynum, const char *binding)
// allocate memory for new binding // allocate memory for new binding
if (binding) if (binding)
keybindings[keynum] = Z_Strdup(binding); keybindings[keynum] = Z_Strdup(binding);
printf("%d is now %s\n", keynum, keybindings[keynum]);
} }
/* /*
@@ -639,16 +640,16 @@ void Key_Unbind_f (void)
{ {
int b; int b;
if (Cmd_Argc() != 2) if (command::argc() != 2)
{ {
Con_Printf ("unbind <key> : remove commands from a key\n"); Con_Printf ("unbind <key> : remove commands from a key\n");
return; return;
} }
b = Key_StringToKeynum (Cmd_Argv(1)); b = Key_StringToKeynum (command::argv(1)->c_str());
if (b == -1) if (b == -1)
{ {
Con_Printf ("\"%s\" isn't a valid key\n", Cmd_Argv(1)); Con_Printf ("\"%s\" isn't a valid key\n", command::argv(1)->c_str());
return; return;
} }
@@ -697,26 +698,26 @@ void Key_Bind_f (void)
int i, c, b; int i, c, b;
char cmd[1024]; char cmd[1024];
c = Cmd_Argc(); c = command::argc();
if (c != 2 && c != 3) if (c != 2 && c != 3)
{ {
Con_Printf ("bind <key> [command] : attach a command to a key\n"); Con_Printf ("bind <key> [command] : attach a command to a key\n");
return; return;
} }
b = Key_StringToKeynum (Cmd_Argv(1)); b = Key_StringToKeynum (command::argv(1)->c_str());
if (b == -1) if (b == -1)
{ {
Con_Printf ("\"%s\" isn't a valid key\n", Cmd_Argv(1)); Con_Printf ("\"%s\" isn't a valid key\n", command::argv(1)->c_str());
return; return;
} }
if (c == 2) if (c == 2)
{ {
if (keybindings[b]) if (keybindings[b])
Con_Printf ("\"%s\" = \"%s\"\n", Cmd_Argv(1), keybindings[b] ); Con_Printf ("\"%s\" = \"%s\"\n", command::argv(1)->c_str(), keybindings[b] );
else else
Con_Printf ("\"%s\" is not bound\n", Cmd_Argv(1) ); Con_Printf ("\"%s\" is not bound\n", command::argv(1)->c_str() );
return; return;
} }
@@ -724,7 +725,7 @@ void Key_Bind_f (void)
cmd[0] = 0; cmd[0] = 0;
for (i = 2; i < c; i++) for (i = 2; i < c; i++)
{ {
q_strlcat (cmd, Cmd_Argv(i), sizeof(cmd)); q_strlcat (cmd, command::argv(i)->c_str(), sizeof(cmd));
if (i != (c-1)) if (i != (c-1))
q_strlcat (cmd, " ", sizeof(cmd)); q_strlcat (cmd, " ", sizeof(cmd));
} }
@@ -890,10 +891,10 @@ void Key_Init (void)
// //
// register our functions // register our functions
// //
Cmd_AddCommand ("bindlist",Key_Bindlist_f); //johnfitz command::add ("bindlist",Key_Bindlist_f); //johnfitz
Cmd_AddCommand ("bind",Key_Bind_f); command::add ("bind",Key_Bind_f);
Cmd_AddCommand ("unbind",Key_Unbind_f); command::add ("unbind",Key_Unbind_f);
Cmd_AddCommand ("unbindall",Key_Unbindall_f); command::add ("unbindall",Key_Unbindall_f);
} }
static struct { static struct {
+295 -423
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -5,6 +5,7 @@
#define MINIZ_EXPORT #define MINIZ_EXPORT
#endif #endif
/* miniz.c 2.2.0 - public domain deflate/inflate, zlib-subset, ZIP reading/writing/appending, PNG writing /* miniz.c 2.2.0 - public domain deflate/inflate, zlib-subset, ZIP reading/writing/appending, PNG writing
See "unlicense" statement at the end of this file. See "unlicense" statement at the end of this file.
Rich Geldreich <richgel99@gmail.com>, last updated Oct. 13, 2013 Rich Geldreich <richgel99@gmail.com>, last updated Oct. 13, 2013
+1 -1
View File
@@ -39,7 +39,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern int DEFAULTnet_hostport; extern int DEFAULTnet_hostport;
extern int net_hostport; extern int net_hostport;
extern cvar_t hostname; extern convar hostname;
extern double net_time; extern double net_time;
extern sizebuf_t net_message; extern sizebuf_t net_message;
+144 -277
View File
@@ -43,8 +43,7 @@ static int receivedDuplicateCount = 0;
static int shortPacketCount = 0; static int shortPacketCount = 0;
static int droppedDatagrams; static int droppedDatagrams;
static struct static struct {
{
unsigned int length; unsigned int length;
unsigned int sequence; unsigned int sequence;
byte data[MAX_DATAGRAM]; byte data[MAX_DATAGRAM];
@@ -56,8 +55,7 @@ extern qboolean m_return_onerror;
extern char m_return_reason[32]; extern char m_return_reason[32];
static char *StrAddr (struct qsockaddr *addr) static char *StrAddr(struct qsockaddr *addr) {
{
static char buf[34]; static char buf[34];
byte *p = (byte *) addr; byte *p = (byte *) addr;
int n; int n;
@@ -73,52 +71,44 @@ static char *StrAddr (struct qsockaddr *addr)
static struct in_addr banAddr; static struct in_addr banAddr;
static struct in_addr banMask; static struct in_addr banMask;
static void NET_Ban_f (void) static void NET_Ban_f(void) {
{
char addrStr[32]; char addrStr[32];
char maskStr[32]; char maskStr[32];
void (*print_fn)(const char *fmt, ...) FUNCP_PRINTF(1, 2); void (*print_fn)(const char *fmt, ...) FUNCP_PRINTF(1, 2);
if (cmd_source == src_command) if (command::last_source == command::source::command) {
{ if (!sv.active) {
if (!sv.active) command::forward_to_server();
{
Cmd_ForwardToServer ();
return; return;
} }
print_fn = Con_Printf; print_fn = Con_Printf;
} } else {
else
{
if (pr_global_struct->deathmatch) if (pr_global_struct->deathmatch)
return; return;
print_fn = SV_ClientPrintf; print_fn = SV_ClientPrintf;
} }
switch (Cmd_Argc ()) switch (command::argc()) {
{
case 1: case 1:
if (banAddr.s_addr != INADDR_ANY) if (banAddr.s_addr != INADDR_ANY) {
{
Q_strcpy(addrStr, inet_ntoa(banAddr)); Q_strcpy(addrStr, inet_ntoa(banAddr));
Q_strcpy(maskStr, inet_ntoa(banMask)); Q_strcpy(maskStr, inet_ntoa(banMask));
print_fn("Banning %s [%s]\n", addrStr, maskStr); print_fn("Banning %s [%s]\n", addrStr, maskStr);
} } else
else
print_fn("Banning not active\n"); print_fn("Banning not active\n");
break; break;
case 2: case 2:
if (q_strcasecmp(Cmd_Argv(1), "off") == 0) if (q_strcasecmp(command::argv(1)->c_str(), "off") == 0)
banAddr.s_addr = INADDR_ANY; banAddr.s_addr = INADDR_ANY;
else else
banAddr.s_addr = inet_addr(Cmd_Argv(1)); banAddr.s_addr = inet_addr(command::argv(1)->c_str());
banMask.s_addr = INADDR_NONE; banMask.s_addr = INADDR_NONE;
break; break;
case 3: case 3:
banAddr.s_addr = inet_addr(Cmd_Argv(1)); banAddr.s_addr = inet_addr(command::argv(1)->c_str());
banMask.s_addr = inet_addr(Cmd_Argv(2)); banMask.s_addr = inet_addr(command::argv(2)->c_str());
break; break;
default: default:
@@ -129,8 +119,7 @@ static void NET_Ban_f (void)
#endif // BAN_TEST #endif // BAN_TEST
int Datagram_SendMessage (qsocket_t *sock, sizebuf_t *data) int Datagram_SendMessage(qsocket_t *sock, sizebuf_t *data) {
{
unsigned int packetLen; unsigned int packetLen;
unsigned int dataLen; unsigned int dataLen;
unsigned int eom; unsigned int eom;
@@ -149,13 +138,10 @@ int Datagram_SendMessage (qsocket_t *sock, sizebuf_t *data)
Q_memcpy(sock->sendMessage, data->data, data->cursize); Q_memcpy(sock->sendMessage, data->data, data->cursize);
sock->sendMessageLength = data->cursize; sock->sendMessageLength = data->cursize;
if (data->cursize <= MAX_DATAGRAM) if (data->cursize <= MAX_DATAGRAM) {
{
dataLen = data->cursize; dataLen = data->cursize;
eom = NETFLAG_EOM; eom = NETFLAG_EOM;
} } else {
else
{
dataLen = MAX_DATAGRAM; dataLen = MAX_DATAGRAM;
eom = 0; eom = 0;
} }
@@ -176,19 +162,15 @@ int Datagram_SendMessage (qsocket_t *sock, sizebuf_t *data)
} }
static int SendMessageNext (qsocket_t *sock) static int SendMessageNext(qsocket_t *sock) {
{
unsigned int packetLen; unsigned int packetLen;
unsigned int dataLen; unsigned int dataLen;
unsigned int eom; unsigned int eom;
if (sock->sendMessageLength <= MAX_DATAGRAM) if (sock->sendMessageLength <= MAX_DATAGRAM) {
{
dataLen = sock->sendMessageLength; dataLen = sock->sendMessageLength;
eom = NETFLAG_EOM; eom = NETFLAG_EOM;
} } else {
else
{
dataLen = MAX_DATAGRAM; dataLen = MAX_DATAGRAM;
eom = 0; eom = 0;
} }
@@ -209,19 +191,15 @@ static int SendMessageNext (qsocket_t *sock)
} }
static int ReSendMessage (qsocket_t *sock) static int ReSendMessage(qsocket_t *sock) {
{
unsigned int packetLen; unsigned int packetLen;
unsigned int dataLen; unsigned int dataLen;
unsigned int eom; unsigned int eom;
if (sock->sendMessageLength <= MAX_DATAGRAM) if (sock->sendMessageLength <= MAX_DATAGRAM) {
{
dataLen = sock->sendMessageLength; dataLen = sock->sendMessageLength;
eom = NETFLAG_EOM; eom = NETFLAG_EOM;
} } else {
else
{
dataLen = MAX_DATAGRAM; dataLen = MAX_DATAGRAM;
eom = 0; eom = 0;
} }
@@ -242,8 +220,7 @@ static int ReSendMessage (qsocket_t *sock)
} }
qboolean Datagram_CanSendMessage (qsocket_t *sock) qboolean Datagram_CanSendMessage(qsocket_t *sock) {
{
if (sock->sendNext) if (sock->sendNext)
SendMessageNext(sock); SendMessageNext(sock);
@@ -251,14 +228,12 @@ qboolean Datagram_CanSendMessage (qsocket_t *sock)
} }
qboolean Datagram_CanSendUnreliableMessage (qsocket_t *sock) qboolean Datagram_CanSendUnreliableMessage(qsocket_t *sock) {
{
return true; return true;
} }
int Datagram_SendUnreliableMessage (qsocket_t *sock, sizebuf_t *data) int Datagram_SendUnreliableMessage(qsocket_t *sock, sizebuf_t *data) {
{
int packetLen; int packetLen;
#ifdef DEBUG #ifdef DEBUG
@@ -283,8 +258,7 @@ int Datagram_SendUnreliableMessage (qsocket_t *sock, sizebuf_t *data)
} }
int Datagram_GetMessage (qsocket_t *sock) int Datagram_GetMessage(qsocket_t *sock) {
{
unsigned int length; unsigned int length;
unsigned int flags; unsigned int flags;
int ret = 0; int ret = 0;
@@ -296,8 +270,7 @@ int Datagram_GetMessage (qsocket_t *sock)
if ((net_time - sock->lastSendTime) > 1.0) if ((net_time - sock->lastSendTime) > 1.0)
ReSendMessage(sock); ReSendMessage(sock);
while (1) while (1) {
{
length = (unsigned int) sfunc.Read(sock->socket, (byte *) &packetBuffer, length = (unsigned int) sfunc.Read(sock->socket, (byte *) &packetBuffer,
NET_DATAGRAMSIZE, &readaddr); NET_DATAGRAMSIZE, &readaddr);
@@ -307,22 +280,19 @@ int Datagram_GetMessage (qsocket_t *sock)
if (length == 0) if (length == 0)
break; break;
if (length == (unsigned int)-1) if (length == (unsigned int) -1) {
{
Con_Printf("Read error\n"); Con_Printf("Read error\n");
return -1; return -1;
} }
if (sfunc.AddrCompare(&readaddr, &sock->addr) != 0) if (sfunc.AddrCompare(&readaddr, &sock->addr) != 0) {
{
Con_Printf("Forged packet received\n"); Con_Printf("Forged packet received\n");
Con_Printf("Expected: %s\n", StrAddr(&sock->addr)); Con_Printf("Expected: %s\n", StrAddr(&sock->addr));
Con_Printf("Received: %s\n", StrAddr(&readaddr)); Con_Printf("Received: %s\n", StrAddr(&readaddr));
continue; continue;
} }
if (length < NET_HEADERSIZE) if (length < NET_HEADERSIZE) {
{
shortPacketCount++; shortPacketCount++;
continue; continue;
} }
@@ -337,16 +307,13 @@ int Datagram_GetMessage (qsocket_t *sock)
sequence = BigLong(packetBuffer.sequence); sequence = BigLong(packetBuffer.sequence);
packetsReceived++; packetsReceived++;
if (flags & NETFLAG_UNRELIABLE) if (flags & NETFLAG_UNRELIABLE) {
{ if (sequence < sock->unreliableReceiveSequence) {
if (sequence < sock->unreliableReceiveSequence)
{
Con_DPrintf("Got a stale datagram\n"); Con_DPrintf("Got a stale datagram\n");
ret = 0; ret = 0;
break; break;
} }
if (sequence != sock->unreliableReceiveSequence) if (sequence != sock->unreliableReceiveSequence) {
{
count = sequence - sock->unreliableReceiveSequence; count = sequence - sock->unreliableReceiveSequence;
droppedDatagrams += count; droppedDatagrams += count;
Con_DPrintf("Dropped %u datagram(s)\n", count); Con_DPrintf("Dropped %u datagram(s)\n", count);
@@ -362,46 +329,36 @@ int Datagram_GetMessage (qsocket_t *sock)
break; break;
} }
if (flags & NETFLAG_ACK) if (flags & NETFLAG_ACK) {
{ if (sequence != (sock->sendSequence - 1)) {
if (sequence != (sock->sendSequence - 1))
{
Con_DPrintf("Stale ACK received\n"); Con_DPrintf("Stale ACK received\n");
continue; continue;
} }
if (sequence == sock->ackSequence) if (sequence == sock->ackSequence) {
{
sock->ackSequence++; sock->ackSequence++;
if (sock->ackSequence != sock->sendSequence) if (sock->ackSequence != sock->sendSequence)
Con_DPrintf("ack sequencing error\n"); Con_DPrintf("ack sequencing error\n");
} } else {
else
{
Con_DPrintf("Duplicate ACK received\n"); Con_DPrintf("Duplicate ACK received\n");
continue; continue;
} }
sock->sendMessageLength -= MAX_DATAGRAM; sock->sendMessageLength -= MAX_DATAGRAM;
if (sock->sendMessageLength > 0) if (sock->sendMessageLength > 0) {
{
memmove(sock->sendMessage, sock->sendMessage + MAX_DATAGRAM, sock->sendMessageLength); memmove(sock->sendMessage, sock->sendMessage + MAX_DATAGRAM, sock->sendMessageLength);
sock->sendNext = true; sock->sendNext = true;
} } else {
else
{
sock->sendMessageLength = 0; sock->sendMessageLength = 0;
sock->canSend = true; sock->canSend = true;
} }
continue; continue;
} }
if (flags & NETFLAG_DATA) if (flags & NETFLAG_DATA) {
{
packetBuffer.length = BigLong(NET_HEADERSIZE | NETFLAG_ACK); packetBuffer.length = BigLong(NET_HEADERSIZE | NETFLAG_ACK);
packetBuffer.sequence = BigLong(sequence); packetBuffer.sequence = BigLong(sequence);
sfunc.Write(sock->socket, (byte *) &packetBuffer, NET_HEADERSIZE, &readaddr); sfunc.Write(sock->socket, (byte *) &packetBuffer, NET_HEADERSIZE, &readaddr);
if (sequence != sock->receiveSequence) if (sequence != sock->receiveSequence) {
{
receivedDuplicateCount++; receivedDuplicateCount++;
continue; continue;
} }
@@ -409,8 +366,7 @@ int Datagram_GetMessage (qsocket_t *sock)
length -= NET_HEADERSIZE; length -= NET_HEADERSIZE;
if (flags & NETFLAG_EOM) if (flags & NETFLAG_EOM) {
{
SZ_Clear(&net_message); SZ_Clear(&net_message);
SZ_Write(&net_message, sock->receiveMessage, sock->receiveMessageLength); SZ_Write(&net_message, sock->receiveMessage, sock->receiveMessageLength);
SZ_Write(&net_message, packetBuffer.data, length); SZ_Write(&net_message, packetBuffer.data, length);
@@ -433,20 +389,17 @@ int Datagram_GetMessage (qsocket_t *sock)
} }
static void PrintStats(qsocket_t *s) static void PrintStats(qsocket_t *s) {
{
Con_Printf("canSend = %4u \n", s->canSend); Con_Printf("canSend = %4u \n", s->canSend);
Con_Printf("sendSeq = %4u ", s->sendSequence); Con_Printf("sendSeq = %4u ", s->sendSequence);
Con_Printf("recvSeq = %4u \n", s->receiveSequence); Con_Printf("recvSeq = %4u \n", s->receiveSequence);
Con_Printf("\n"); Con_Printf("\n");
} }
static void NET_Stats_f (void) static void NET_Stats_f(void) {
{
qsocket_t *s; qsocket_t *s;
if (Cmd_Argc () == 1) if (command::argc() == 1) {
{
Con_Printf("unreliable messages sent = %i\n", unreliableMessagesSent); Con_Printf("unreliable messages sent = %i\n", unreliableMessagesSent);
Con_Printf("unreliable messages recv = %i\n", unreliableMessagesReceived); Con_Printf("unreliable messages recv = %i\n", unreliableMessagesReceived);
Con_Printf("reliable messages sent = %i\n", messagesSent); Con_Printf("reliable messages sent = %i\n", messagesSent);
@@ -457,27 +410,20 @@ static void NET_Stats_f (void)
Con_Printf("receivedDuplicateCount = %i\n", receivedDuplicateCount); Con_Printf("receivedDuplicateCount = %i\n", receivedDuplicateCount);
Con_Printf("shortPacketCount = %i\n", shortPacketCount); Con_Printf("shortPacketCount = %i\n", shortPacketCount);
Con_Printf("droppedDatagrams = %i\n", droppedDatagrams); Con_Printf("droppedDatagrams = %i\n", droppedDatagrams);
} } else if (Q_strcmp(command::argv(1)->c_str(), "*") == 0) {
else if (Q_strcmp(Cmd_Argv(1), "*") == 0)
{
for (s = net_activeSockets; s; s = s->next) for (s = net_activeSockets; s; s = s->next)
PrintStats(s); PrintStats(s);
for (s = net_freeSockets; s; s = s->next) for (s = net_freeSockets; s; s = s->next)
PrintStats(s); PrintStats(s);
} } else {
else for (s = net_activeSockets; s; s = s->next) {
{ if (q_strcasecmp(command::argv(1)->c_str(), s->address) == 0)
for (s = net_activeSockets; s; s = s->next)
{
if (q_strcasecmp(Cmd_Argv(1), s->address) == 0)
break; break;
} }
if (s == NULL) if (s == NULL) {
{ for (s = net_freeSockets; s; s = s->next) {
for (s = net_freeSockets; s; s = s->next) if (q_strcasecmp(command::argv(1)->c_str(), s->address) == 0)
{
if (q_strcasecmp(Cmd_Argv(1), s->address) == 0)
break; break;
} }
} }
@@ -491,8 +437,7 @@ static void NET_Stats_f (void)
// recognize ip:port (based on ProQuake) // recognize ip:port (based on ProQuake)
static const char *Strip_Port (const char *host) static const char *Strip_Port(const char *host) {
{
static char noport[MAX_QPATH]; static char noport[MAX_QPATH];
/* array size as in Host_Connect_f() */ /* array size as in Host_Connect_f() */
char *p; char *p;
@@ -505,8 +450,7 @@ static const char *Strip_Port (const char *host)
return host; return host;
*p++ = '\0'; *p++ = '\0';
port = Q_atoi(p); port = Q_atoi(p);
if (port > 0 && port < 65536 && port != net_hostport) if (port > 0 && port < 65536 && port != net_hostport) {
{
net_hostport = port; net_hostport = port;
Con_Printf("Port set to %d\n", net_hostport); Con_Printf("Port set to %d\n", net_hostport);
} }
@@ -520,10 +464,10 @@ static int testDriver;
static sys_socket_t testSocket; static sys_socket_t testSocket;
static void Test_Poll(void *); static void Test_Poll(void *);
static PollProcedure testPollProcedure = {NULL, 0.0, Test_Poll}; static PollProcedure testPollProcedure = {NULL, 0.0, Test_Poll};
static void Test_Poll (void *unused) static void Test_Poll(void *unused) {
{
struct qsockaddr clientaddr; struct qsockaddr clientaddr;
int control; int control;
int len; int len;
@@ -535,8 +479,7 @@ static void Test_Poll (void *unused)
net_landriverlevel = testDriver; net_landriverlevel = testDriver;
while (1) while (1) {
{
len = dfunc.Read(testSocket, net_message.data, net_message.maxsize, &clientaddr); len = dfunc.Read(testSocket, net_message.data, net_message.maxsize, &clientaddr);
if (len < (int) sizeof(int)) if (len < (int) sizeof(int))
break; break;
@@ -563,23 +506,20 @@ static void Test_Poll (void *unused)
connectTime = MSG_ReadLong(); connectTime = MSG_ReadLong();
Q_strcpy(address, MSG_ReadString()); Q_strcpy(address, MSG_ReadString());
Con_Printf("%s\n frags:%3i colors:%d %d time:%d\n %s\n", name, frags, colors >> 4, colors & 0x0f, connectTime / 60, address); Con_Printf("%s\n frags:%3i colors:%d %d time:%d\n %s\n", name, frags, colors >> 4, colors & 0x0f,
connectTime / 60, address);
} }
testPollCount--; testPollCount--;
if (testPollCount) if (testPollCount) {
{
SchedulePollProcedure(&testPollProcedure, 0.1); SchedulePollProcedure(&testPollProcedure, 0.1);
} } else {
else
{
dfunc.Close_Socket(testSocket); dfunc.Close_Socket(testSocket);
testInProgress = false; testInProgress = false;
} }
} }
static void Test_f (void) static void Test_f(void) {
{
const char *host; const char *host;
int n; int n;
int maxusers = MAX_SCOREBOARD; int maxusers = MAX_SCOREBOARD;
@@ -588,14 +528,11 @@ static void Test_f (void)
if (testInProgress) if (testInProgress)
return; return;
host = Strip_Port (Cmd_Argv(1)); host = Strip_Port(command::argv(1).value_or("").c_str());
if (host && hostCacheCount) if (host && hostCacheCount) {
{ for (n = 0; n < hostCacheCount; n++) {
for (n = 0; n < hostCacheCount; n++) if (q_strcasecmp(host, hostcache[n].name) == 0) {
{
if (q_strcasecmp (host, hostcache[n].name) == 0)
{
if (hostcache[n].driver != myDriverLevel) if (hostcache[n].driver != myDriverLevel)
continue; continue;
net_landriverlevel = hostcache[n].ldriver; net_landriverlevel = hostcache[n].ldriver;
@@ -609,8 +546,7 @@ static void Test_f (void)
goto JustDoIt; goto JustDoIt;
} }
for (net_landriverlevel = 0; net_landriverlevel < net_numlandrivers; net_landriverlevel++) for (net_landriverlevel = 0; net_landriverlevel < net_numlandrivers; net_landriverlevel++) {
{
if (!net_landrivers[net_landriverlevel].initialized) if (!net_landrivers[net_landriverlevel].initialized)
continue; continue;
@@ -619,8 +555,7 @@ static void Test_f (void)
break; break;
} }
if (net_landriverlevel == net_numlandrivers) if (net_landriverlevel == net_numlandrivers) {
{
Con_Printf("Could not resolve %s\n", host); Con_Printf("Could not resolve %s\n", host);
return; return;
} }
@@ -634,8 +569,7 @@ JustDoIt:
testPollCount = 20; testPollCount = 20;
testDriver = net_landriverlevel; testDriver = net_landriverlevel;
for (n = 0; n < maxusers; n++) for (n = 0; n < maxusers; n++) {
{
SZ_Clear(&net_message); SZ_Clear(&net_message);
// save space for the header, filled in later // save space for the header, filled in later
MSG_WriteLong(&net_message, 0); MSG_WriteLong(&net_message, 0);
@@ -654,10 +588,10 @@ static int test2Driver;
static sys_socket_t test2Socket; static sys_socket_t test2Socket;
static void Test2_Poll(void *); static void Test2_Poll(void *);
static PollProcedure test2PollProcedure = {NULL, 0.0, Test2_Poll}; static PollProcedure test2PollProcedure = {NULL, 0.0, Test2_Poll};
static void Test2_Poll (void *unused) static void Test2_Poll(void *unused) {
{
struct qsockaddr clientaddr; struct qsockaddr clientaddr;
int control; int control;
int len; int len;
@@ -714,8 +648,7 @@ Done:
return; return;
} }
static void Test2_f (void) static void Test2_f(void) {
{
const char *host; const char *host;
int n; int n;
struct qsockaddr sendaddr; struct qsockaddr sendaddr;
@@ -723,14 +656,11 @@ static void Test2_f (void)
if (test2InProgress) if (test2InProgress)
return; return;
host = Strip_Port (Cmd_Argv(1)); host = Strip_Port(command::argv(1).value_or("").c_str());
if (host && hostCacheCount) if (host && hostCacheCount) {
{ for (n = 0; n < hostCacheCount; n++) {
for (n = 0; n < hostCacheCount; n++) if (q_strcasecmp(host, hostcache[n].name) == 0) {
{
if (q_strcasecmp (host, hostcache[n].name) == 0)
{
if (hostcache[n].driver != myDriverLevel) if (hostcache[n].driver != myDriverLevel)
continue; continue;
net_landriverlevel = hostcache[n].ldriver; net_landriverlevel = hostcache[n].ldriver;
@@ -743,8 +673,7 @@ static void Test2_f (void)
goto JustDoIt; goto JustDoIt;
} }
for (net_landriverlevel = 0; net_landriverlevel < net_numlandrivers; net_landriverlevel++) for (net_landriverlevel = 0; net_landriverlevel < net_numlandrivers; net_landriverlevel++) {
{
if (!net_landrivers[net_landriverlevel].initialized) if (!net_landrivers[net_landriverlevel].initialized)
continue; continue;
@@ -753,8 +682,7 @@ static void Test2_f (void)
break; break;
} }
if (net_landriverlevel == net_numlandrivers) if (net_landriverlevel == net_numlandrivers) {
{
Con_Printf("Could not resolve %s\n", host); Con_Printf("Could not resolve %s\n", host);
return; return;
} }
@@ -779,8 +707,7 @@ JustDoIt:
} }
int Datagram_Init (void) int Datagram_Init(void) {
{
int i, num_inited; int i, num_inited;
sys_socket_t csock; sys_socket_t csock;
@@ -790,14 +717,13 @@ int Datagram_Init (void)
#endif #endif
myDriverLevel = net_driverlevel; myDriverLevel = net_driverlevel;
Cmd_AddCommand ("net_stats", NET_Stats_f); command::add("net_stats", NET_Stats_f);
if (safemode || COM_CheckParm("-nolan")) if (safemode || COM_CheckParm("-nolan"))
return -1; return -1;
num_inited = 0; num_inited = 0;
for (i = 0; i < net_numlandrivers; i++) for (i = 0; i < net_numlandrivers; i++) {
{
csock = net_landrivers[i].Init(); csock = net_landrivers[i].Init();
if (csock == INVALID_SOCKET) if (csock == INVALID_SOCKET)
continue; continue;
@@ -810,26 +736,23 @@ int Datagram_Init (void)
return -1; return -1;
#ifdef BAN_TEST #ifdef BAN_TEST
Cmd_AddCommand ("ban", NET_Ban_f); command::add("ban", NET_Ban_f);
#endif #endif
Cmd_AddCommand ("test", Test_f); command::add("test", Test_f);
Cmd_AddCommand ("test2", Test2_f); command::add("test2", Test2_f);
return 0; return 0;
} }
void Datagram_Shutdown (void) void Datagram_Shutdown(void) {
{
int i; int i;
// //
// shutdown the lan drivers // shutdown the lan drivers
// //
for (i = 0; i < net_numlandrivers; i++) for (i = 0; i < net_numlandrivers; i++) {
{ if (net_landrivers[i].initialized) {
if (net_landrivers[i].initialized)
{
net_landrivers[i].Shutdown(); net_landrivers[i].Shutdown();
net_landrivers[i].initialized = false; net_landrivers[i].initialized = false;
} }
@@ -837,26 +760,22 @@ void Datagram_Shutdown (void)
} }
void Datagram_Close (qsocket_t *sock) void Datagram_Close(qsocket_t *sock) {
{
sfunc.Close_Socket(sock->socket); sfunc.Close_Socket(sock->socket);
} }
void Datagram_Listen (qboolean state) void Datagram_Listen(qboolean state) {
{
int i; int i;
for (i = 0; i < net_numlandrivers; i++) for (i = 0; i < net_numlandrivers; i++) {
{
if (net_landrivers[i].initialized) if (net_landrivers[i].initialized)
net_landrivers[i].Listen(state); net_landrivers[i].Listen(state);
} }
} }
static qsocket_t *_Datagram_CheckNewConnections (void) static qsocket_t *_Datagram_CheckNewConnections(void) {
{
struct qsockaddr clientaddr; struct qsockaddr clientaddr;
struct qsockaddr newaddr; struct qsockaddr newaddr;
sys_socket_t newsock; sys_socket_t newsock;
@@ -890,8 +809,7 @@ static qsocket_t *_Datagram_CheckNewConnections (void)
return NULL; return NULL;
command = MSG_ReadByte(); command = MSG_ReadByte();
if (command == CCREQ_SERVER_INFO) if (command == CCREQ_SERVER_INFO) {
{
if (Q_strcmp(MSG_ReadString(), "QUAKE") != 0) if (Q_strcmp(MSG_ReadString(), "QUAKE") != 0)
return NULL; return NULL;
@@ -912,8 +830,7 @@ static qsocket_t *_Datagram_CheckNewConnections (void)
return NULL; return NULL;
} }
if (command == CCREQ_PLAYER_INFO) if (command == CCREQ_PLAYER_INFO) {
{
int playerNumber; int playerNumber;
int activeNumber; int activeNumber;
int clientNumber; int clientNumber;
@@ -922,10 +839,8 @@ static qsocket_t *_Datagram_CheckNewConnections (void)
playerNumber = MSG_ReadByte(); playerNumber = MSG_ReadByte();
activeNumber = -1; activeNumber = -1;
for (clientNumber = 0, client = svs.clients; clientNumber < svs.maxclients; clientNumber++, client++) for (clientNumber = 0, client = svs.clients; clientNumber < svs.maxclients; clientNumber++, client++) {
{ if (client->active) {
if (client->active)
{
activeNumber++; activeNumber++;
if (activeNumber == playerNumber) if (activeNumber == playerNumber)
break; break;
@@ -952,24 +867,21 @@ static qsocket_t *_Datagram_CheckNewConnections (void)
return NULL; return NULL;
} }
if (command == CCREQ_RULE_INFO) if (command == CCREQ_RULE_INFO) {
{
const char *prevCvarName; const char *prevCvarName;
cvar_t *var;
// find the search start location // find the search start location
prevCvarName = MSG_ReadString(); prevCvarName = MSG_ReadString();
var = Cvar_FindVarAfter (prevCvarName, CVAR_SERVERINFO); auto var = convar::find_var_after(prevCvarName, std::nullopt);
// send the response // send the response
SZ_Clear(&net_message); SZ_Clear(&net_message);
// save space for the header, filled in later // save space for the header, filled in later
MSG_WriteLong(&net_message, 0); MSG_WriteLong(&net_message, 0);
MSG_WriteByte(&net_message, CCREP_RULE_INFO); MSG_WriteByte(&net_message, CCREP_RULE_INFO);
if (var) if (var) {
{ MSG_WriteString(&net_message, var.value()->name.c_str());
MSG_WriteString(&net_message, var->name); MSG_WriteString(&net_message, var.value()->string);
MSG_WriteString(&net_message, var->string);
} }
*((int *) net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK)); *((int *) net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK));
dfunc.Write(acceptsock, net_message.data, net_message.cursize, &clientaddr); dfunc.Write(acceptsock, net_message.data, net_message.cursize, &clientaddr);
@@ -984,8 +896,7 @@ static qsocket_t *_Datagram_CheckNewConnections (void)
if (Q_strcmp(MSG_ReadString(), "QUAKE") != 0) if (Q_strcmp(MSG_ReadString(), "QUAKE") != 0)
return NULL; return NULL;
if (MSG_ReadByte() != NET_PROTOCOL_VERSION) if (MSG_ReadByte() != NET_PROTOCOL_VERSION) {
{
SZ_Clear(&net_message); SZ_Clear(&net_message);
// save space for the header, filled in later // save space for the header, filled in later
MSG_WriteLong(&net_message, 0); MSG_WriteLong(&net_message, 0);
@@ -999,12 +910,10 @@ static qsocket_t *_Datagram_CheckNewConnections (void)
#ifdef BAN_TEST #ifdef BAN_TEST
// check for a ban // check for a ban
if (clientaddr.qsa_family == AF_INET) if (clientaddr.qsa_family == AF_INET) {
{
in_addr_t testAddr; in_addr_t testAddr;
testAddr = ((struct sockaddr_in *) &clientaddr)->sin_addr.s_addr; testAddr = ((struct sockaddr_in *) &clientaddr)->sin_addr.s_addr;
if ((testAddr & banMask.s_addr) == banAddr.s_addr) if ((testAddr & banMask.s_addr) == banAddr.s_addr) {
{
SZ_Clear(&net_message); SZ_Clear(&net_message);
// save space for the header, filled in later // save space for the header, filled in later
MSG_WriteLong(&net_message, 0); MSG_WriteLong(&net_message, 0);
@@ -1019,16 +928,13 @@ static qsocket_t *_Datagram_CheckNewConnections (void)
#endif #endif
// see if this guy is already connected // see if this guy is already connected
for (s = net_activeSockets; s; s = s->next) for (s = net_activeSockets; s; s = s->next) {
{
if (s->driver != net_driverlevel) if (s->driver != net_driverlevel)
continue; continue;
ret = dfunc.AddrCompare(&clientaddr, &s->addr); ret = dfunc.AddrCompare(&clientaddr, &s->addr);
if (ret >= 0) if (ret >= 0) {
{
// is this a duplicate connection reqeust? // is this a duplicate connection reqeust?
if (ret == 0 && net_time - s->connecttime < 2.0) if (ret == 0 && net_time - s->connecttime < 2.0) {
{
// yes, so send a duplicate reply // yes, so send a duplicate reply
SZ_Clear(&net_message); SZ_Clear(&net_message);
// save space for the header, filled in later // save space for the header, filled in later
@@ -1065,15 +971,13 @@ static qsocket_t *_Datagram_CheckNewConnections (void)
// allocate a network socket // allocate a network socket
newsock = dfunc.Open_Socket(0); newsock = dfunc.Open_Socket(0);
if (newsock == INVALID_SOCKET) if (newsock == INVALID_SOCKET) {
{
NET_FreeQSocket(sock); NET_FreeQSocket(sock);
return NULL; return NULL;
} }
// connect to the client // connect to the client
if (dfunc.Connect (newsock, &clientaddr) == -1) if (dfunc.Connect(newsock, &clientaddr) == -1) {
{
dfunc.Close_Socket(newsock); dfunc.Close_Socket(newsock);
NET_FreeQSocket(sock); NET_FreeQSocket(sock);
return NULL; return NULL;
@@ -1100,14 +1004,11 @@ static qsocket_t *_Datagram_CheckNewConnections (void)
return sock; return sock;
} }
qsocket_t *Datagram_CheckNewConnections (void) qsocket_t *Datagram_CheckNewConnections(void) {
{
qsocket_t *ret = NULL; qsocket_t *ret = NULL;
for (net_landriverlevel = 0; net_landriverlevel < net_numlandrivers; net_landriverlevel++) for (net_landriverlevel = 0; net_landriverlevel < net_numlandrivers; net_landriverlevel++) {
{ if (net_landrivers[net_landriverlevel].initialized) {
if (net_landrivers[net_landriverlevel].initialized)
{
if ((ret = _Datagram_CheckNewConnections()) != NULL) if ((ret = _Datagram_CheckNewConnections()) != NULL)
break; break;
} }
@@ -1116,8 +1017,7 @@ qsocket_t *Datagram_CheckNewConnections (void)
} }
static void _Datagram_SearchForHosts (qboolean xmit) static void _Datagram_SearchForHosts(qboolean xmit) {
{
int ret; int ret;
int n; int n;
int i; int i;
@@ -1126,8 +1026,7 @@ static void _Datagram_SearchForHosts (qboolean xmit)
int control; int control;
dfunc.GetSocketAddr(dfunc.controlSock, &myaddr); dfunc.GetSocketAddr(dfunc.controlSock, &myaddr);
if (xmit) if (xmit) {
{
SZ_Clear(&net_message); SZ_Clear(&net_message);
// save space for the header, filled in later // save space for the header, filled in later
MSG_WriteLong(&net_message, 0); MSG_WriteLong(&net_message, 0);
@@ -1139,8 +1038,7 @@ static void _Datagram_SearchForHosts (qboolean xmit)
SZ_Clear(&net_message); SZ_Clear(&net_message);
} }
while ((ret = dfunc.Read (dfunc.controlSock, net_message.data, net_message.maxsize, &readaddr)) > 0) while ((ret = dfunc.Read(dfunc.controlSock, net_message.data, net_message.maxsize, &readaddr)) > 0) {
{
if (ret < (int) sizeof(int)) if (ret < (int) sizeof(int))
continue; continue;
net_message.cursize = ret; net_message.cursize = ret;
@@ -1168,8 +1066,7 @@ static void _Datagram_SearchForHosts (qboolean xmit)
dfunc.GetAddrFromName(MSG_ReadString(), &readaddr); dfunc.GetAddrFromName(MSG_ReadString(), &readaddr);
// search the cache for this server // search the cache for this server
for (n = 0; n < hostCacheCount; n++) for (n = 0; n < hostCacheCount; n++) {
{
if (dfunc.AddrCompare(&readaddr, &hostcache[n].addr) == 0) if (dfunc.AddrCompare(&readaddr, &hostcache[n].addr) == 0)
break; break;
} }
@@ -1184,8 +1081,7 @@ static void _Datagram_SearchForHosts (qboolean xmit)
Q_strcpy(hostcache[n].map, MSG_ReadString()); Q_strcpy(hostcache[n].map, MSG_ReadString());
hostcache[n].users = MSG_ReadByte(); hostcache[n].users = MSG_ReadByte();
hostcache[n].maxusers = MSG_ReadByte(); hostcache[n].maxusers = MSG_ReadByte();
if (MSG_ReadByte() != NET_PROTOCOL_VERSION) if (MSG_ReadByte() != NET_PROTOCOL_VERSION) {
{
Q_strcpy(hostcache[n].cname, hostcache[n].name); Q_strcpy(hostcache[n].cname, hostcache[n].name);
hostcache[n].cname[14] = 0; hostcache[n].cname[14] = 0;
Q_strcpy(hostcache[n].name, "*"); Q_strcpy(hostcache[n].name, "*");
@@ -1197,19 +1093,15 @@ static void _Datagram_SearchForHosts (qboolean xmit)
Q_strcpy(hostcache[n].cname, dfunc.AddrToString(&readaddr)); Q_strcpy(hostcache[n].cname, dfunc.AddrToString(&readaddr));
// check for a name conflict // check for a name conflict
for (i = 0; i < hostCacheCount; i++) for (i = 0; i < hostCacheCount; i++) {
{
if (i == n) if (i == n)
continue; continue;
if (q_strcasecmp (hostcache[n].name, hostcache[i].name) == 0) if (q_strcasecmp(hostcache[n].name, hostcache[i].name) == 0) {
{
i = Q_strlen(hostcache[n].name); i = Q_strlen(hostcache[n].name);
if (i < 15 && hostcache[n].name[i-1] > '8') if (i < 15 && hostcache[n].name[i - 1] > '8') {
{
hostcache[n].name[i] = '0'; hostcache[n].name[i] = '0';
hostcache[n].name[i + 1] = 0; hostcache[n].name[i + 1] = 0;
} } else
else
hostcache[n].name[i - 1]++; hostcache[n].name[i - 1]++;
i = -1; i = -1;
@@ -1218,10 +1110,8 @@ static void _Datagram_SearchForHosts (qboolean xmit)
} }
} }
void Datagram_SearchForHosts (qboolean xmit) void Datagram_SearchForHosts(qboolean xmit) {
{ for (net_landriverlevel = 0; net_landriverlevel < net_numlandrivers; net_landriverlevel++) {
for (net_landriverlevel = 0; net_landriverlevel < net_numlandrivers; net_landriverlevel++)
{
if (hostCacheCount == HOSTCACHESIZE) if (hostCacheCount == HOSTCACHESIZE)
break; break;
if (net_landrivers[net_landriverlevel].initialized) if (net_landrivers[net_landriverlevel].initialized)
@@ -1230,8 +1120,7 @@ void Datagram_SearchForHosts (qboolean xmit)
} }
static qsocket_t *_Datagram_Connect (const char *host) static qsocket_t *_Datagram_Connect(const char *host) {
{
struct qsockaddr sendaddr; struct qsockaddr sendaddr;
struct qsockaddr readaddr; struct qsockaddr readaddr;
qsocket_t *sock; qsocket_t *sock;
@@ -1243,8 +1132,7 @@ static qsocket_t *_Datagram_Connect (const char *host)
const char *reason; const char *reason;
// see if we can resolve the host name // see if we can resolve the host name
if (dfunc.GetAddrFromName(host, &sendaddr) == -1) if (dfunc.GetAddrFromName(host, &sendaddr) == -1) {
{
Con_Printf("Could not resolve %s\n", host); Con_Printf("Could not resolve %s\n", host);
return NULL; return NULL;
} }
@@ -1268,8 +1156,7 @@ static qsocket_t *_Datagram_Connect (const char *host)
SCR_UpdateScreen(); SCR_UpdateScreen();
start_time = net_time; start_time = net_time;
for (reps = 0; reps < 3; reps++) for (reps = 0; reps < 3; reps++) {
{
SZ_Clear(&net_message); SZ_Clear(&net_message);
// save space for the header, filled in later // save space for the header, filled in later
MSG_WriteLong(&net_message, 0); MSG_WriteLong(&net_message, 0);
@@ -1279,15 +1166,12 @@ static qsocket_t *_Datagram_Connect (const char *host)
*((int *) net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK)); *((int *) net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK));
dfunc.Write(newsock, net_message.data, net_message.cursize, &sendaddr); dfunc.Write(newsock, net_message.data, net_message.cursize, &sendaddr);
SZ_Clear(&net_message); SZ_Clear(&net_message);
do do {
{
ret = dfunc.Read(newsock, net_message.data, net_message.maxsize, &readaddr); ret = dfunc.Read(newsock, net_message.data, net_message.maxsize, &readaddr);
// if we got something, validate it // if we got something, validate it
if (ret > 0) if (ret > 0) {
{
// is it from the right place? // is it from the right place?
if (sfunc.AddrCompare(&readaddr, &sendaddr) != 0) if (sfunc.AddrCompare(&readaddr, &sendaddr) != 0) {
{
Con_Printf("wrong reply address\n"); Con_Printf("wrong reply address\n");
Con_Printf("Expected: %s | %s\n", dfunc.AddrToString(&sendaddr), StrAddr(&sendaddr)); Con_Printf("Expected: %s | %s\n", dfunc.AddrToString(&sendaddr), StrAddr(&sendaddr));
Con_Printf("Received: %s | %s\n", dfunc.AddrToString(&readaddr), StrAddr(&readaddr)); Con_Printf("Received: %s | %s\n", dfunc.AddrToString(&readaddr), StrAddr(&readaddr));
@@ -1296,8 +1180,7 @@ static qsocket_t *_Datagram_Connect (const char *host)
continue; continue;
} }
if (ret < (int) sizeof(int)) if (ret < (int) sizeof(int)) {
{
ret = 0; ret = 0;
continue; continue;
} }
@@ -1307,24 +1190,20 @@ static qsocket_t *_Datagram_Connect (const char *host)
control = BigLong(*((int *) net_message.data)); control = BigLong(*((int *) net_message.data));
MSG_ReadLong(); MSG_ReadLong();
if (control == -1) if (control == -1) {
{
ret = 0; ret = 0;
continue; continue;
} }
if ((control & (~NETFLAG_LENGTH_MASK)) != (int)NETFLAG_CTL) if ((control & (~NETFLAG_LENGTH_MASK)) != (int) NETFLAG_CTL) {
{
ret = 0; ret = 0;
continue; continue;
} }
if ((control & NETFLAG_LENGTH_MASK) != ret) if ((control & NETFLAG_LENGTH_MASK) != ret) {
{
ret = 0; ret = 0;
continue; continue;
} }
} }
} } while (ret == 0 && (SetNetTime() - start_time) < 2.5);
while (ret == 0 && (SetNetTime() - start_time) < 2.5);
if (ret) if (ret)
break; break;
@@ -1334,16 +1213,14 @@ static qsocket_t *_Datagram_Connect (const char *host)
start_time = SetNetTime(); start_time = SetNetTime();
} }
if (ret == 0) if (ret == 0) {
{
reason = "No Response"; reason = "No Response";
Con_Printf("%s\n", reason); Con_Printf("%s\n", reason);
Q_strcpy(m_return_reason, reason); Q_strcpy(m_return_reason, reason);
goto ErrorReturn; goto ErrorReturn;
} }
if (ret == -1) if (ret == -1) {
{
reason = "Network Error"; reason = "Network Error";
Con_Printf("%s\n", reason); Con_Printf("%s\n", reason);
Q_strcpy(m_return_reason, reason); Q_strcpy(m_return_reason, reason);
@@ -1351,21 +1228,17 @@ static qsocket_t *_Datagram_Connect (const char *host)
} }
ret = MSG_ReadByte(); ret = MSG_ReadByte();
if (ret == CCREP_REJECT) if (ret == CCREP_REJECT) {
{
reason = MSG_ReadString(); reason = MSG_ReadString();
Con_Printf("%s\n", reason); Con_Printf("%s\n", reason);
q_strlcpy(m_return_reason, reason, sizeof(m_return_reason)); q_strlcpy(m_return_reason, reason, sizeof(m_return_reason));
goto ErrorReturn; goto ErrorReturn;
} }
if (ret == CCREP_ACCEPT) if (ret == CCREP_ACCEPT) {
{
Q_memcpy(&sock->addr, &sendaddr, sizeof(struct qsockaddr)); Q_memcpy(&sock->addr, &sendaddr, sizeof(struct qsockaddr));
dfunc.SetSocketPort(&sock->addr, MSG_ReadLong()); dfunc.SetSocketPort(&sock->addr, MSG_ReadLong());
} } else {
else
{
reason = "Bad Response"; reason = "Bad Response";
Con_Printf("%s\n", reason); Con_Printf("%s\n", reason);
Q_strcpy(m_return_reason, reason); Q_strcpy(m_return_reason, reason);
@@ -1378,8 +1251,7 @@ static qsocket_t *_Datagram_Connect (const char *host)
sock->lastMessageTime = SetNetTime(); sock->lastMessageTime = SetNetTime();
// switch the connection to the specified address // switch the connection to the specified address
if (dfunc.Connect (newsock, &sock->addr) == -1) if (dfunc.Connect(newsock, &sock->addr) == -1) {
{
reason = "Connect to Game failed"; reason = "Connect to Game failed";
Con_Printf("%s\n", reason); Con_Printf("%s\n", reason);
Q_strcpy(m_return_reason, reason); Q_strcpy(m_return_reason, reason);
@@ -1393,8 +1265,7 @@ ErrorReturn:
NET_FreeQSocket(sock); NET_FreeQSocket(sock);
ErrorReturn2: ErrorReturn2:
dfunc.Close_Socket(newsock); dfunc.Close_Socket(newsock);
if (m_return_onerror) if (m_return_onerror) {
{
IN_Deactivate(modestate == MS_WINDOWED); IN_Deactivate(modestate == MS_WINDOWED);
key_dest = key_menu; key_dest = key_menu;
m_state = m_return_state; m_state = m_return_state;
@@ -1403,19 +1274,15 @@ ErrorReturn2:
return NULL; return NULL;
} }
qsocket_t *Datagram_Connect (const char *host) qsocket_t *Datagram_Connect(const char *host) {
{
qsocket_t *ret = NULL; qsocket_t *ret = NULL;
host = Strip_Port(host); host = Strip_Port(host);
for (net_landriverlevel = 0; net_landriverlevel < net_numlandrivers; net_landriverlevel++) for (net_landriverlevel = 0; net_landriverlevel < net_numlandrivers; net_landriverlevel++) {
{ if (net_landrivers[net_landriverlevel].initialized) {
if (net_landrivers[net_landriverlevel].initialized)
{
if ((ret = _Datagram_Connect(host)) != NULL) if ((ret = _Datagram_Connect(host)) != NULL)
break; break;
} }
} }
return ret; return ret;
} }
+110 -205
View File
@@ -47,7 +47,9 @@ static double slistStartTime;
static int slistLastShown; static int slistLastShown;
static void Slist_Send(void *); static void Slist_Send(void *);
static void Slist_Poll(void *); static void Slist_Poll(void *);
static PollProcedure slistSendProcedure = {NULL, 0.0, Slist_Send}; static PollProcedure slistSendProcedure = {NULL, 0.0, Slist_Send};
static PollProcedure slistPollProcedure = {NULL, 0.0, Slist_Poll}; static PollProcedure slistPollProcedure = {NULL, 0.0, Slist_Poll};
@@ -59,8 +61,8 @@ int messagesReceived = 0;
int unreliableMessagesSent = 0; int unreliableMessagesSent = 0;
int unreliableMessagesReceived = 0; int unreliableMessagesReceived = 0;
static cvar_t net_messagetimeout = {"net_messagetimeout","300",CVAR_NONE}; static convar net_messagetimeout = {"net_messagetimeout", "300"};
cvar_t hostname = {"hostname", "UNNAMED", CVAR_NONE}; convar hostname = {"hostname", "UNNAMED"};
// these two macros are to make the code more readable // these two macros are to make the code more readable
#define sfunc net_drivers[sock->driver] #define sfunc net_drivers[sock->driver]
@@ -71,8 +73,7 @@ int net_driverlevel;
double net_time; double net_time;
double SetNetTime (void) double SetNetTime(void) {
{
net_time = Sys_DoubleTime(); net_time = Sys_DoubleTime();
return net_time; return net_time;
} }
@@ -86,8 +87,7 @@ Called by drivers when a new communications endpoint is required
The sequence and buffer fields will be filled in properly The sequence and buffer fields will be filled in properly
=================== ===================
*/ */
qsocket_t *NET_NewQSocket (void) qsocket_t *NET_NewQSocket(void) {
{
qsocket_t *sock; qsocket_t *sock;
if (net_freeSockets == NULL) if (net_freeSockets == NULL)
@@ -125,19 +125,15 @@ qsocket_t *NET_NewQSocket (void)
} }
void NET_FreeQSocket(qsocket_t *sock) void NET_FreeQSocket(qsocket_t *sock) {
{
qsocket_t *s; qsocket_t *s;
// remove it from active list // remove it from active list
if (sock == net_activeSockets) if (sock == net_activeSockets)
net_activeSockets = net_activeSockets->next; net_activeSockets = net_activeSockets->next;
else else {
{ for (s = net_activeSockets; s; s = s->next) {
for (s = net_activeSockets; s; s = s->next) if (s->next == sock) {
{
if (s->next == sock)
{
s->next = sock->next; s->next = sock->next;
break; break;
} }
@@ -154,30 +150,25 @@ void NET_FreeQSocket(qsocket_t *sock)
} }
double NET_QSocketGetTime (const qsocket_t *s) double NET_QSocketGetTime(const qsocket_t *s) {
{
return s->connecttime; return s->connecttime;
} }
const char *NET_QSocketGetAddressString (const qsocket_t *s) const char *NET_QSocketGetAddressString(const qsocket_t *s) {
{
return s->address; return s->address;
} }
static void NET_Listen_f (void) static void NET_Listen_f(void) {
{ if (command::argc() != 2) {
if (Cmd_Argc () != 2)
{
Con_Printf("\"listen\" is \"%d\"\n", listening ? 1 : 0); Con_Printf("\"listen\" is \"%d\"\n", listening ? 1 : 0);
return; return;
} }
listening = Q_atoi(Cmd_Argv(1)) ? true : false; listening = Q_atoi(command::argv(1)->c_str()) ? true : false;
for (net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++) for (net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++) {
{
if (net_drivers[net_driverlevel].initialized == false) if (net_drivers[net_driverlevel].initialized == false)
continue; continue;
dfunc.Listen(listening); dfunc.Listen(listening);
@@ -185,27 +176,23 @@ static void NET_Listen_f (void)
} }
static void MaxPlayers_f (void) static void MaxPlayers_f(void) {
{
int n; int n;
if (Cmd_Argc () != 2) if (command::argc() != 2) {
{
Con_Printf("\"maxplayers\" is \"%d\"\n", svs.maxclients); Con_Printf("\"maxplayers\" is \"%d\"\n", svs.maxclients);
return; return;
} }
if (sv.active) if (sv.active) {
{
Con_Printf("maxplayers can not be changed while a server is running.\n"); Con_Printf("maxplayers can not be changed while a server is running.\n");
return; return;
} }
n = Q_atoi(Cmd_Argv(1)); n = Q_atoi(command::argv(1)->c_str());
if (n < 1) if (n < 1)
n = 1; n = 1;
if (n > svs.maxclientslimit) if (n > svs.maxclientslimit) {
{
n = svs.maxclientslimit; n = svs.maxclientslimit;
Con_Printf("\"maxplayers\" set to \"%d\"\n", n); Con_Printf("\"maxplayers\" set to \"%d\"\n", n);
} }
@@ -218,25 +205,22 @@ static void MaxPlayers_f (void)
svs.maxclients = n; svs.maxclients = n;
if (n == 1) if (n == 1)
Cvar_Set ("deathmatch", "0"); convar::set("deathmatch", "0");
else else
Cvar_Set ("deathmatch", "1"); convar::set("deathmatch", "1");
} }
static void NET_Port_f (void) static void NET_Port_f(void) {
{
int n; int n;
if (Cmd_Argc () != 2) if (command::argc() != 2) {
{
Con_Printf("\"port\" is \"%d\"\n", net_hostport); Con_Printf("\"port\" is \"%d\"\n", net_hostport);
return; return;
} }
n = Q_atoi(Cmd_Argv(1)); n = Q_atoi(command::argv(1)->c_str());
if (n < 1 || n > 65534) if (n < 1 || n > 65534) {
{
Con_Printf("Bad value, must be between 1 and 65534\n"); Con_Printf("Bad value, must be between 1 and 65534\n");
return; return;
} }
@@ -244,8 +228,7 @@ static void NET_Port_f (void)
DEFAULTnet_hostport = n; DEFAULTnet_hostport = n;
net_hostport = n; net_hostport = n;
if (listening) if (listening) {
{
// force a change to the new port // force a change to the new port
Cbuf_AddText("listen 0\n"); Cbuf_AddText("listen 0\n");
Cbuf_AddText("listen 1\n"); Cbuf_AddText("listen 1\n");
@@ -253,22 +236,20 @@ static void NET_Port_f (void)
} }
static void PrintSlistHeader(void) static void PrintSlistHeader(void) {
{
Con_Printf("Server Map Users\n"); Con_Printf("Server Map Users\n");
Con_Printf("--------------- --------------- -----\n"); Con_Printf("--------------- --------------- -----\n");
slistLastShown = 0; slistLastShown = 0;
} }
static void PrintSlist(void) static void PrintSlist(void) {
{
int n; int n;
for (n = slistLastShown; n < hostCacheCount; n++) for (n = slistLastShown; n < hostCacheCount; n++) {
{
if (hostcache[n].maxusers) if (hostcache[n].maxusers)
Con_Printf("%-15.15s %-15.15s %2u/%2u\n", hostcache[n].name, hostcache[n].map, hostcache[n].users, hostcache[n].maxusers); Con_Printf("%-15.15s %-15.15s %2u/%2u\n", hostcache[n].name, hostcache[n].map, hostcache[n].users,
hostcache[n].maxusers);
else else
Con_Printf("%-15.15s %-15.15s\n", hostcache[n].name, hostcache[n].map); Con_Printf("%-15.15s %-15.15s\n", hostcache[n].name, hostcache[n].map);
} }
@@ -276,8 +257,7 @@ static void PrintSlist(void)
} }
static void PrintSlistTrailer(void) static void PrintSlistTrailer(void) {
{
if (hostCacheCount) if (hostCacheCount)
Con_Printf("== end list ==\n\n"); Con_Printf("== end list ==\n\n");
else else
@@ -285,13 +265,11 @@ static void PrintSlistTrailer(void)
} }
void NET_Slist_f (void) void NET_Slist_f(void) {
{
if (slistInProgress) if (slistInProgress)
return; return;
if (! slistSilent) if (!slistSilent) {
{
Con_Printf("Looking for Quake servers...\n"); Con_Printf("Looking for Quake servers...\n");
PrintSlistHeader(); PrintSlistHeader();
} }
@@ -306,18 +284,13 @@ void NET_Slist_f (void)
} }
void NET_SlistSort (void) void NET_SlistSort(void) {
{ if (hostCacheCount > 1) {
if (hostCacheCount > 1)
{
int i, j; int i, j;
hostcache_t temp; hostcache_t temp;
for (i = 0; i < hostCacheCount; i++) for (i = 0; i < hostCacheCount; i++) {
{ for (j = i + 1; j < hostCacheCount; j++) {
for (j = i + 1; j < hostCacheCount; j++) if (strcmp(hostcache[j].name, hostcache[i].name) < 0) {
{
if (strcmp(hostcache[j].name, hostcache[i].name) < 0)
{
memcpy(&temp, &hostcache[j], sizeof(hostcache_t)); memcpy(&temp, &hostcache[j], sizeof(hostcache_t));
memcpy(&hostcache[j], &hostcache[i], sizeof(hostcache_t)); memcpy(&hostcache[j], &hostcache[i], sizeof(hostcache_t));
memcpy(&hostcache[i], &temp, sizeof(hostcache_t)); memcpy(&hostcache[i], &temp, sizeof(hostcache_t));
@@ -328,21 +301,17 @@ void NET_SlistSort (void)
} }
const char *NET_SlistPrintServer (int idx) const char *NET_SlistPrintServer(int idx) {
{
static char string[64]; static char string[64];
if (idx < 0 || idx >= hostCacheCount) if (idx < 0 || idx >= hostCacheCount)
return ""; return "";
if (hostcache[idx].maxusers) if (hostcache[idx].maxusers) {
{
q_snprintf(string, sizeof(string), "%-15.15s %-15.15s %2u/%2u\n", q_snprintf(string, sizeof(string), "%-15.15s %-15.15s %2u/%2u\n",
hostcache[idx].name, hostcache[idx].map, hostcache[idx].name, hostcache[idx].map,
hostcache[idx].users, hostcache[idx].maxusers); hostcache[idx].users, hostcache[idx].maxusers);
} } else {
else
{
q_snprintf(string, sizeof(string), "%-15.15s %-15.15s\n", q_snprintf(string, sizeof(string), "%-15.15s %-15.15s\n",
hostcache[idx].name, hostcache[idx].map); hostcache[idx].name, hostcache[idx].map);
} }
@@ -351,18 +320,15 @@ const char *NET_SlistPrintServer (int idx)
} }
const char *NET_SlistPrintServerName (int idx) const char *NET_SlistPrintServerName(int idx) {
{
if (idx < 0 || idx >= hostCacheCount) if (idx < 0 || idx >= hostCacheCount)
return ""; return "";
return hostcache[idx].cname; return hostcache[idx].cname;
} }
static void Slist_Send (void *unused) static void Slist_Send(void *unused) {
{ for (net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++) {
for (net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++)
{
if (!slistLocal && IS_LOOP_DRIVER(net_driverlevel)) if (!slistLocal && IS_LOOP_DRIVER(net_driverlevel))
continue; continue;
if (net_drivers[net_driverlevel].initialized == false) if (net_drivers[net_driverlevel].initialized == false)
@@ -375,10 +341,8 @@ static void Slist_Send (void *unused)
} }
static void Slist_Poll (void *unused) static void Slist_Poll(void *unused) {
{ for (net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++) {
for (net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++)
{
if (!slistLocal && IS_LOOP_DRIVER(net_driverlevel)) if (!slistLocal && IS_LOOP_DRIVER(net_driverlevel))
continue; continue;
if (net_drivers[net_driverlevel].initialized == false) if (net_drivers[net_driverlevel].initialized == false)
@@ -389,8 +353,7 @@ static void Slist_Poll (void *unused)
if (!slistSilent) if (!slistSilent)
PrintSlist(); PrintSlist();
if ((Sys_DoubleTime() - slistStartTime) < 1.5) if ((Sys_DoubleTime() - slistStartTime) < 1.5) {
{
SchedulePollProcedure(&slistPollProcedure, 0.1); SchedulePollProcedure(&slistPollProcedure, 0.1);
return; return;
} }
@@ -412,8 +375,7 @@ NET_Connect
int hostCacheCount = 0; int hostCacheCount = 0;
hostcache_t hostcache[HOSTCACHESIZE]; hostcache_t hostcache[HOSTCACHESIZE];
qsocket_t *NET_Connect (const char *host) qsocket_t *NET_Connect(const char *host) {
{
qsocket_t *ret; qsocket_t *ret;
int n; int n;
int numdrivers = net_numdrivers; int numdrivers = net_numdrivers;
@@ -423,19 +385,15 @@ qsocket_t *NET_Connect (const char *host)
if (host && *host == 0) if (host && *host == 0)
host = NULL; host = NULL;
if (host) if (host) {
{ if (q_strcasecmp(host, "local") == 0) {
if (q_strcasecmp (host, "local") == 0)
{
numdrivers = 1; numdrivers = 1;
goto JustDoIt; goto JustDoIt;
} }
if (hostCacheCount) if (hostCacheCount) {
{
for (n = 0; n < hostCacheCount; n++) for (n = 0; n < hostCacheCount; n++)
if (q_strcasecmp (host, hostcache[n].name) == 0) if (q_strcasecmp(host, hostcache[n].name) == 0) {
{
host = hostcache[n].cname; host = hostcache[n].cname;
break; break;
} }
@@ -450,20 +408,16 @@ qsocket_t *NET_Connect (const char *host)
while (slistInProgress) while (slistInProgress)
NET_Poll(); NET_Poll();
if (host == NULL) if (host == NULL) {
{
if (hostCacheCount != 1) if (hostCacheCount != 1)
return NULL; return NULL;
host = hostcache[0].cname; host = hostcache[0].cname;
Con_Printf("Connecting to...\n%s @ %s\n\n", hostcache[0].name, host); Con_Printf("Connecting to...\n%s @ %s\n\n", hostcache[0].name, host);
} }
if (hostCacheCount) if (hostCacheCount) {
{ for (n = 0; n < hostCacheCount; n++) {
for (n = 0; n < hostCacheCount; n++) if (q_strcasecmp(host, hostcache[n].name) == 0) {
{
if (q_strcasecmp (host, hostcache[n].name) == 0)
{
host = hostcache[n].cname; host = hostcache[n].cname;
break; break;
} }
@@ -471,8 +425,7 @@ qsocket_t *NET_Connect (const char *host)
} }
JustDoIt: JustDoIt:
for (net_driverlevel = 0; net_driverlevel < numdrivers; net_driverlevel++) for (net_driverlevel = 0; net_driverlevel < numdrivers; net_driverlevel++) {
{
if (net_drivers[net_driverlevel].initialized == false) if (net_drivers[net_driverlevel].initialized == false)
continue; continue;
ret = dfunc.Connect(host); ret = dfunc.Connect(host);
@@ -480,8 +433,7 @@ JustDoIt:
return ret; return ret;
} }
if (host) if (host) {
{
Con_Printf("\n"); Con_Printf("\n");
PrintSlistHeader(); PrintSlistHeader();
PrintSlist(); PrintSlist();
@@ -497,21 +449,18 @@ JustDoIt:
NET_CheckNewConnections NET_CheckNewConnections
=================== ===================
*/ */
qsocket_t *NET_CheckNewConnections (void) qsocket_t *NET_CheckNewConnections(void) {
{
qsocket_t *ret; qsocket_t *ret;
SetNetTime(); SetNetTime();
for (net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++) for (net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++) {
{
if (net_drivers[net_driverlevel].initialized == false) if (net_drivers[net_driverlevel].initialized == false)
continue; continue;
if (!IS_LOOP_DRIVER(net_driverlevel) && listening == false) if (!IS_LOOP_DRIVER(net_driverlevel) && listening == false)
continue; continue;
ret = dfunc.CheckNewConnections(); ret = dfunc.CheckNewConnections();
if (ret) if (ret) {
{
return ret; return ret;
} }
} }
@@ -524,8 +473,7 @@ qsocket_t *NET_CheckNewConnections (void)
NET_Close NET_Close
=================== ===================
*/ */
void NET_Close (qsocket_t *sock) void NET_Close(qsocket_t *sock) {
{
if (!sock) if (!sock)
return; return;
@@ -552,15 +500,13 @@ returns 1 if a message was received
returns -1 if connection is invalid returns -1 if connection is invalid
================= =================
*/ */
int NET_GetMessage (qsocket_t *sock) int NET_GetMessage(qsocket_t *sock) {
{
int ret; int ret;
if (!sock) if (!sock)
return -1; return -1;
if (sock->disconnected) if (sock->disconnected) {
{
Con_Printf("NET_GetMessage: disconnected socket\n"); Con_Printf("NET_GetMessage: disconnected socket\n");
return -1; return -1;
} }
@@ -570,19 +516,15 @@ int NET_GetMessage (qsocket_t *sock)
ret = sfunc.QGetMessage(sock); ret = sfunc.QGetMessage(sock);
// see if this connection has timed out // see if this connection has timed out
if (ret == 0 && !IS_LOOP_DRIVER(sock->driver)) if (ret == 0 && !IS_LOOP_DRIVER(sock->driver)) {
{ if (net_time - sock->lastMessageTime > net_messagetimeout.value) {
if (net_time - sock->lastMessageTime > net_messagetimeout.value)
{
NET_Close(sock); NET_Close(sock);
return -1; return -1;
} }
} }
if (ret > 0) if (ret > 0) {
{ if (!IS_LOOP_DRIVER(sock->driver)) {
if (!IS_LOOP_DRIVER(sock->driver))
{
sock->lastMessageTime = net_time; sock->lastMessageTime = net_time;
if (ret == 1) if (ret == 1)
messagesReceived++; messagesReceived++;
@@ -606,15 +548,13 @@ returns 1 if the message was sent properly
returns -1 if the connection died returns -1 if the connection died
================== ==================
*/ */
int NET_SendMessage (qsocket_t *sock, sizebuf_t *data) int NET_SendMessage(qsocket_t *sock, sizebuf_t *data) {
{
int r; int r;
if (!sock) if (!sock)
return -1; return -1;
if (sock->disconnected) if (sock->disconnected) {
{
Con_Printf("NET_SendMessage: disconnected socket\n"); Con_Printf("NET_SendMessage: disconnected socket\n");
return -1; return -1;
} }
@@ -628,15 +568,13 @@ int NET_SendMessage (qsocket_t *sock, sizebuf_t *data)
} }
int NET_SendUnreliableMessage (qsocket_t *sock, sizebuf_t *data) int NET_SendUnreliableMessage(qsocket_t *sock, sizebuf_t *data) {
{
int r; int r;
if (!sock) if (!sock)
return -1; return -1;
if (sock->disconnected) if (sock->disconnected) {
{
Con_Printf("NET_SendMessage: disconnected socket\n"); Con_Printf("NET_SendMessage: disconnected socket\n");
return -1; return -1;
} }
@@ -658,8 +596,7 @@ Returns true or false if the given qsocket can currently accept a
message to be transmitted. message to be transmitted.
================== ==================
*/ */
qboolean NET_CanSendMessage (qsocket_t *sock) qboolean NET_CanSendMessage(qsocket_t *sock) {
{
if (!sock) if (!sock)
return false; return false;
@@ -672,25 +609,21 @@ qboolean NET_CanSendMessage (qsocket_t *sock)
} }
int NET_SendToAll (sizebuf_t *data, double blocktime) int NET_SendToAll(sizebuf_t *data, double blocktime) {
{
double start; double start;
int i; int i;
int count = 0; int count = 0;
qboolean msg_init[MAX_SCOREBOARD]; /* did we write the message to the client's connection */ qboolean msg_init[MAX_SCOREBOARD]; /* did we write the message to the client's connection */
qboolean msg_sent[MAX_SCOREBOARD]; /* did the msg arrive its destination (canSend state). */ qboolean msg_sent[MAX_SCOREBOARD]; /* did the msg arrive its destination (canSend state). */
for (i = 0, host_client = svs.clients; i < svs.maxclients; i++, host_client++) for (i = 0, host_client = svs.clients; i < svs.maxclients; i++, host_client++) {
{
/* /*
if (!host_client->netconnection) if (!host_client->netconnection)
continue; continue;
if (host_client->active) if (host_client->active)
*/ */
if (host_client->netconnection && host_client->active) if (host_client->netconnection && host_client->active) {
{ if (IS_LOOP_DRIVER(host_client->netconnection->driver)) {
if (IS_LOOP_DRIVER(host_client->netconnection->driver))
{
NET_SendMessage(host_client->netconnection, data); NET_SendMessage(host_client->netconnection, data);
msg_init[i] = true; msg_init[i] = true;
msg_sent[i] = true; msg_sent[i] = true;
@@ -699,43 +632,31 @@ int NET_SendToAll (sizebuf_t *data, double blocktime)
count++; count++;
msg_init[i] = false; msg_init[i] = false;
msg_sent[i] = false; msg_sent[i] = false;
} } else {
else
{
msg_init[i] = true; msg_init[i] = true;
msg_sent[i] = true; msg_sent[i] = true;
} }
} }
start = Sys_DoubleTime(); start = Sys_DoubleTime();
while (count) while (count) {
{
count = 0; count = 0;
for (i = 0, host_client = svs.clients; i < svs.maxclients; i++, host_client++) for (i = 0, host_client = svs.clients; i < svs.maxclients; i++, host_client++) {
{ if (!msg_init[i]) {
if (! msg_init[i]) if (NET_CanSendMessage(host_client->netconnection)) {
{
if (NET_CanSendMessage (host_client->netconnection))
{
msg_init[i] = true; msg_init[i] = true;
NET_SendMessage(host_client->netconnection, data); NET_SendMessage(host_client->netconnection, data);
} } else {
else
{
NET_GetMessage(host_client->netconnection); NET_GetMessage(host_client->netconnection);
} }
count++; count++;
continue; continue;
} }
if (! msg_sent[i]) if (!msg_sent[i]) {
{ if (NET_CanSendMessage(host_client->netconnection)) {
if (NET_CanSendMessage (host_client->netconnection))
{
msg_sent[i] = true; msg_sent[i] = true;
} } else {
else
{
NET_GetMessage(host_client->netconnection); NET_GetMessage(host_client->netconnection);
} }
count++; count++;
@@ -757,8 +678,7 @@ NET_Init
==================== ====================
*/ */
void NET_Init (void) void NET_Init(void) {
{
int i; int i;
qsocket_t *s; qsocket_t *s;
@@ -768,8 +688,7 @@ void NET_Init (void)
if (!i) if (!i)
i = COM_CheckParm("-ipxport"); i = COM_CheckParm("-ipxport");
if (i) if (i) {
{
if (i < com_argc - 1) if (i < com_argc - 1)
DEFAULTnet_hostport = Q_atoi(com_argv[i + 1]); DEFAULTnet_hostport = Q_atoi(com_argv[i + 1]);
else else
@@ -785,8 +704,7 @@ void NET_Init (void)
SetNetTime(); SetNetTime();
for (i = 0; i < net_numsockets; i++) for (i = 0; i < net_numsockets; i++) {
{
s = (qsocket_t *) Hunk_AllocName(sizeof(qsocket_t), "qsocket"); s = (qsocket_t *) Hunk_AllocName(sizeof(qsocket_t), "qsocket");
s->next = net_freeSockets; s->next = net_freeSockets;
net_freeSockets = s; net_freeSockets = s;
@@ -796,17 +714,16 @@ void NET_Init (void)
// allocate space for network message buffer // allocate space for network message buffer
SZ_Alloc(&net_message, NET_MAXMESSAGE); SZ_Alloc(&net_message, NET_MAXMESSAGE);
Cvar_RegisterVariable (&net_messagetimeout); net_messagetimeout.inscribe();
Cvar_RegisterVariable (&hostname); hostname.inscribe();
Cmd_AddCommand ("slist", NET_Slist_f); command::add("slist", NET_Slist_f);
Cmd_AddCommand ("listen", NET_Listen_f); command::add("listen", NET_Listen_f);
Cmd_AddCommand ("maxplayers", MaxPlayers_f); command::add("maxplayers", MaxPlayers_f);
Cmd_AddCommand ("port", NET_Port_f); command::add("port", NET_Port_f);
// initialize all the drivers // initialize all the drivers
for (i = net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++) for (i = net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++) {
{
if (net_drivers[net_driverlevel].Init() == -1) if (net_drivers[net_driverlevel].Init() == -1)
continue; continue;
i++; i++;
@@ -819,17 +736,14 @@ void NET_Init (void)
* therefore the i == 0 check is correct */ * therefore the i == 0 check is correct */
if (i == 0 if (i == 0
&& cls.state == ca_dedicated && cls.state == ca_dedicated
) ) {
{
Sys_Error("Network not available!"); Sys_Error("Network not available!");
} }
if (*my_ipx_address) if (*my_ipx_address) {
{
Con_DPrintf("IPX address %s\n", my_ipx_address); Con_DPrintf("IPX address %s\n", my_ipx_address);
} }
if (*my_tcpip_address) if (*my_tcpip_address) {
{
Con_DPrintf("TCP/IP address %s\n", my_tcpip_address); Con_DPrintf("TCP/IP address %s\n", my_tcpip_address);
} }
} }
@@ -840,8 +754,7 @@ NET_Shutdown
==================== ====================
*/ */
void NET_Shutdown (void) void NET_Shutdown(void) {
{
qsocket_t *sock; qsocket_t *sock;
SetNetTime(); SetNetTime();
@@ -852,10 +765,8 @@ void NET_Shutdown (void)
// //
// shutdown the drivers // shutdown the drivers
// //
for (net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++) for (net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++) {
{ if (net_drivers[net_driverlevel].initialized == true) {
if (net_drivers[net_driverlevel].initialized == true)
{
net_drivers[net_driverlevel].Shutdown(); net_drivers[net_driverlevel].Shutdown();
net_drivers[net_driverlevel].initialized = false; net_drivers[net_driverlevel].initialized = false;
} }
@@ -865,14 +776,12 @@ void NET_Shutdown (void)
static PollProcedure *pollProcedureList = NULL; static PollProcedure *pollProcedureList = NULL;
void NET_Poll(void) void NET_Poll(void) {
{
PollProcedure *pp; PollProcedure *pp;
SetNetTime(); SetNetTime();
for (pp = pollProcedureList; pp; pp = pp->next) for (pp = pollProcedureList; pp; pp = pp->next) {
{
if (pp->nextTime > net_time) if (pp->nextTime > net_time)
break; break;
pollProcedureList = pp->next; pollProcedureList = pp->next;
@@ -881,20 +790,17 @@ void NET_Poll(void)
} }
void SchedulePollProcedure(PollProcedure *proc, double timeOffset) void SchedulePollProcedure(PollProcedure *proc, double timeOffset) {
{
PollProcedure *pp, *prev; PollProcedure *pp, *prev;
proc->nextTime = Sys_DoubleTime() + timeOffset; proc->nextTime = Sys_DoubleTime() + timeOffset;
for (pp = pollProcedureList, prev = NULL; pp; pp = pp->next) for (pp = pollProcedureList, prev = NULL; pp; pp = pp->next) {
{
if (pp->nextTime >= proc->nextTime) if (pp->nextTime >= proc->nextTime)
break; break;
prev = pp; prev = pp;
} }
if (prev == NULL) if (prev == NULL) {
{
proc->next = pollProcedureList; proc->next = pollProcedureList;
pollProcedureList = proc; pollProcedureList = proc;
return; return;
@@ -903,4 +809,3 @@ void SchedulePollProcedure(PollProcedure *proc, double timeOffset)
proc->next = pp; proc->next = pp;
prev->next = proc; prev->next = proc;
} }
+1 -1
View File
@@ -80,7 +80,7 @@ char *PL_GetClipboardData (void)
* such as an ip address, etc: do chop the size * such as an ip address, etc: do chop the size
* here, otherwise we may experience Z_Malloc() * here, otherwise we may experience Z_Malloc()
* failures and all other not-oh-so-fun stuff. */ * failures and all other not-oh-so-fun stuff. */
size = q_min((size_t)(MAX_CLIPBOARDTXT), size); size = std::min((size_t)(MAX_CLIPBOARDTXT), size);
data = (char *) Z_Malloc((int)size); data = (char *) Z_Malloc((int)size);
q_strlcpy (data, cliptext, size); q_strlcpy (data, cliptext, size);
} }
+1 -1
View File
@@ -67,7 +67,7 @@ char *PL_GetClipboardData (void)
if (srcdata != NULL) if (srcdata != NULL)
{ {
size_t sz = [clipboardString length] + 1; size_t sz = [clipboardString length] + 1;
sz = q_min((size_t)(MAX_CLIPBOARDTXT), sz); sz = std::min((size_t)(MAX_CLIPBOARDTXT), sz);
data = (char *) Z_Malloc((int)sz); data = (char *) Z_Malloc((int)sz);
q_strlcpy (data, srcdata, sz); q_strlcpy (data, srcdata, sz);
} }
+1 -1
View File
@@ -95,7 +95,7 @@ char *PL_GetClipboardData (void)
* such as an ip address, etc: do chop the size * such as an ip address, etc: do chop the size
* here, otherwise we may experience Z_Malloc() * here, otherwise we may experience Z_Malloc()
* failures and all other not-oh-so-fun stuff. */ * failures and all other not-oh-so-fun stuff. */
size = q_min((size_t)(MAX_CLIPBOARDTXT), size); size = std::min((size_t)(MAX_CLIPBOARDTXT), size);
data = (char *) Z_Malloc((int)size); data = (char *) Z_Malloc((int)size);
q_strlcpy (data, cliptext, size); q_strlcpy (data, cliptext, size);
GlobalUnlock (hClipboardData); GlobalUnlock (hClipboardData);
+3 -3
View File
@@ -930,7 +930,7 @@ static void PF_cvar (void)
str = G_STRING(OFS_PARM0); str = G_STRING(OFS_PARM0);
G_FLOAT(OFS_RETURN) = Cvar_VariableValue (str); G_FLOAT(OFS_RETURN) = convar::variable_value(str).value_or(0.0);
} }
/* /*
@@ -947,7 +947,7 @@ static void PF_cvar_set (void)
var = G_STRING(OFS_PARM0); var = G_STRING(OFS_PARM0);
val = G_STRING(OFS_PARM1); val = G_STRING(OFS_PARM1);
Cvar_Set (var, val); convar::set (var, val);
} }
/* /*
@@ -1378,7 +1378,7 @@ Pick a vector for the player to shoot along
vector aim(entity, missilespeed) vector aim(entity, missilespeed)
============= =============
*/ */
cvar_t sv_aim = {"sv_aim", "1", CVAR_NONE}; // ericw -- turn autoaim off by default. was 0.93 convar sv_aim{"sv_aim", "1"}; // ericw -- turn autoaim off by default. was 0.93
static void PF_aim (void) static void PF_aim (void)
{ {
edict_t *ent, *check, *bestent; edict_t *ent, *check, *bestent;
+84 -77
View File
@@ -21,6 +21,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
// sv_edict.c -- entity dictionary // sv_edict.c -- entity dictionary
#include <sstream>
#include "quakedef.hpp" #include "quakedef.hpp"
dprograms_t *progs; dprograms_t *progs;
@@ -72,17 +74,17 @@ static gefv_cache gefvCache[GEFV_CACHESIZE] =
{ NULL, "" } { NULL, "" }
}; };
cvar_t nomonsters = {"nomonsters", "0", CVAR_NONE}; convar nomonsters{"nomonsters", "0"};
cvar_t gamecfg = {"gamecfg", "0", CVAR_NONE}; convar gamecfg{"gamecfg", "0"};
cvar_t scratch1 = {"scratch1", "0", CVAR_NONE}; convar scratch1{"scratch1", "0"};
cvar_t scratch2 = {"scratch2", "0", CVAR_NONE}; convar scratch2{"scratch2", "0"};
cvar_t scratch3 = {"scratch3", "0", CVAR_NONE}; convar scratch3{"scratch3", "0"};
cvar_t scratch4 = {"scratch4", "0", CVAR_NONE}; convar scratch4{"scratch4", "0"};
cvar_t savedgamecfg = {"savedgamecfg", "0", CVAR_ARCHIVE}; convar savedgamecfg{"savedgamecfg", "0", {.archive = true}};
cvar_t saved1 = {"saved1", "0", CVAR_ARCHIVE}; convar saved1{"saved1", "0", {.archive = true}};
cvar_t saved2 = {"saved2", "0", CVAR_ARCHIVE}; convar saved2{"saved2", "0", {.archive = true}};
cvar_t saved3 = {"saved3", "0", CVAR_ARCHIVE}; convar saved3{"saved3", "0", {.archive = true}};
cvar_t saved4 = {"saved4", "0", CVAR_ARCHIVE}; convar saved4{"saved4", "0", {.archive = true}};
/* /*
================= =================
@@ -619,7 +621,7 @@ static void ED_PrintEdict_f (void)
if (!sv.active) if (!sv.active)
return; return;
i = Q_atoi (Cmd_Argv(1)); i = Q_atoi (command::argv(1).value_or("").c_str());
if (i < 0 || i >= sv.num_edicts) if (i < 0 || i >= sv.num_edicts)
{ {
Con_Printf("Bad edict number\n"); Con_Printf("Bad edict number\n");
@@ -711,41 +713,43 @@ void ED_WriteGlobals (FILE *f)
ED_ParseGlobals ED_ParseGlobals
============= =============
*/ */
const char *ED_ParseGlobals (const char *data) void ED_ParseGlobals (std::istringstream &ss)
{ {
char keyname[64];
ddef_t *key; ddef_t *key;
while (1) std::string keyname;
while (true)
{ {
// parse key // parse key
data = COM_Parse (data); auto token = common::parse_token(ss);
if (com_token[0] == '}') if (token.has_value() && token->front() == '}') {
break; break;
if (!data) }
if (ss.eof()) {
Host_Error ("ED_ParseEntity: EOF without closing brace"); Host_Error ("ED_ParseEntity: EOF without closing brace");
}
q_strlcpy (keyname, com_token, sizeof(keyname)); keyname = token.value();
// parse value // parse value
data = COM_Parse (data); token = common::parse_token(ss);
if (!data) if (ss.eof())
Host_Error ("ED_ParseEntity: EOF without closing brace"); Host_Error ("ED_ParseEntity: EOF without closing brace");
if (com_token[0] == '}') if (token->front() == '}')
Host_Error ("ED_ParseEntity: closing brace without data"); Host_Error ("ED_ParseEntity: closing brace without data");
key = ED_FindGlobal (keyname); key = ED_FindGlobal (keyname.c_str());
if (!key) if (!key)
{ {
Con_Printf ("'%s' is not a global\n", keyname); Con_Printf ("'%s' is not a global\n", keyname.c_str());
continue; continue;
} }
if (!ED_ParseEpair ((void *)pr_globals, key, com_token)) if (!ED_ParseEpair ((void *)pr_globals, key, token->c_str()))
Host_Error ("ED_ParseGlobals: parse error"); Host_Error ("ED_ParseGlobals: parse error");
} }
return data;
} }
//============================================================================ //============================================================================
@@ -879,13 +883,14 @@ ed should be a properly initialized empty edict.
Used for initial level load and for savegames. Used for initial level load and for savegames.
==================== ====================
*/ */
const char *ED_ParseEdict (const char *data, edict_t *ent) void ED_ParseEdict(std::istringstream &ss, edict_t *ent)
{ {
ddef_t *key; ddef_t *key;
char keyname[256];
qboolean anglehack, init; qboolean anglehack, init;
int n; int n;
std::string keyname{};
init = false; init = false;
// clear it // clear it
@@ -896,83 +901,82 @@ const char *ED_ParseEdict (const char *data, edict_t *ent)
while (1) while (1)
{ {
// parse key // parse key
data = COM_Parse (data); auto token = common::parse_token(ss);
if (com_token[0] == '}') if (token.has_value() && token->front() == '}') {
break; break;
if (!data) }
if (ss.eof()) {
Host_Error ("ED_ParseEntity: EOF without closing brace"); Host_Error ("ED_ParseEntity: EOF without closing brace");
}
// anglehack is to allow QuakeEd to write single scalar angles // anglehack is to allow QuakeEd to write single scalar angles
// and allow them to be turned into vectors. (FIXME...) // and allow them to be turned into vectors. (FIXME...)
if (!strcmp(com_token, "angle")) if (token == "angle")
{ {
strcpy (com_token, "angles"); token = "angles";
anglehack = true; anglehack = true;
} }
else else
anglehack = false; anglehack = false;
// FIXME: change light to _light to get rid of this hack // FIXME: change light to _light to get rid of this hack
if (!strcmp(com_token, "light")) if (token == "light") {
strcpy (com_token, "light_lev"); // hack for single light def token = "light_lev";
}
q_strlcpy (keyname, com_token, sizeof(keyname)); keyname = *token;
// another hack to fix keynames with trailing spaces // another hack to fix keynames with trailing spaces
n = strlen(keyname); while (!keyname.empty() && keyname.back() == ' ') {
while (n && keyname[n-1] == ' ') keyname.pop_back();
{
keyname[n-1] = 0;
n--;
} }
// parse value // parse value
// HACK: we allow truncation when reading the wad field, // HACK: we allow truncation when reading the wad field,
// otherwise maps using lots of wads with absolute paths // otherwise maps using lots of wads with absolute paths
// could cause a parse error // could cause a parse error
data = COM_ParseEx (data, !strcmp (keyname, "wad") ? CPE_ALLOWTRUNC : CPE_NOTRUNC); token = common::parse_token(ss);
if (!data) if (ss.eof()) {
Host_Error ("ED_ParseEntity: EOF without closing brace"); Host_Error ("ED_ParseEntity: EOF without closing brace");
}
if (com_token[0] == '}') if (token->front() == '}') {
Host_Error ("ED_ParseEntity: closing brace without data"); Host_Error ("ED_ParseEntity: closing brace without data");
}
init = true; init = true;
// keynames with a leading underscore are used for utility comments, // keynames with a leading underscore are used for utility comments,
// and are immediately discarded by quake // and are immediately discarded by quake
if (keyname[0] == '_') if (keyname[0] == '_') {
continue; continue;
}
//johnfitz -- hack to support .alpha even when progs.dat doesn't know about it //johnfitz -- hack to support .alpha even when progs.dat doesn't know about it
if (!strcmp(keyname, "alpha")) if (keyname == "alpha")
ent->alpha = ENTALPHA_ENCODE(Q_atof(com_token)); ent->alpha = ENTALPHA_ENCODE(Q_atof(token->c_str()));
//johnfitz //johnfitz
key = ED_FindField (keyname); key = ED_FindField (keyname.c_str());
if (!key) if (!key)
{ {
//johnfitz -- HACK -- suppress error becuase fog/sky/alpha fields might not be mentioned in defs.qc //johnfitz -- HACK -- suppress error becuase fog/sky/alpha fields might not be mentioned in defs.qc
if (strncmp(keyname, "sky", 3) && strcmp(keyname, "fog") && strcmp(keyname, "alpha")) if (keyname != "sky" && keyname != "fog" && keyname != "alpha")
Con_DPrintf ("\"%s\" is not a field\n", keyname); //johnfitz -- was Con_Printf Con_DPrintf ("\"%s\" is not a field\n", keyname.c_str()); //johnfitz -- was Con_Printf
continue; continue;
} }
if (anglehack) if (anglehack)
{ {
char temp[32]; token = std::format("0 {} 0", *token);
strcpy (temp, com_token);
sprintf (com_token, "0 %s 0", temp);
} }
if (!ED_ParseEpair ((void *)&ent->v, key, com_token)) if (!ED_ParseEpair ((void *)&ent->v, key, token->c_str()))
Host_Error ("ED_ParseEdict: parse error"); Host_Error ("ED_ParseEdict: parse error");
} }
if (!init) if (!init)
ent->free = true; ent->free = true;
return data;
} }
@@ -999,21 +1003,24 @@ void ED_LoadFromFile (const char *data)
pr_global_struct->time = sv.time; pr_global_struct->time = sv.time;
std::istringstream ss{data};
// parse ents // parse ents
while (1) while (true)
{ {
// parse the opening brace // parse the opening brace
data = COM_Parse (data); auto token = common::parse_token(ss);
if (!data) if (ss.eof())
break; break;
if (com_token[0] != '{') if (token->front() != '{')
Host_Error ("ED_LoadFromFile: found %s when expecting {",com_token); Host_Error ("ED_LoadFromFile: found %s when expecting {", token->c_str());
if (!ent) if (!ent)
ent = EDICT_NUM(0); ent = EDICT_NUM(0);
else else
ent = ED_Alloc (); ent = ED_Alloc ();
data = ED_ParseEdict (data, ent); ED_ParseEdict (ss, ent);
// remove things from different skill levels or deathmatch // remove things from different skill levels or deathmatch
if (deathmatch.value) if (deathmatch.value)
@@ -1270,21 +1277,21 @@ PR_Init
*/ */
void PR_Init (void) void PR_Init (void)
{ {
Cmd_AddCommand ("edict", ED_PrintEdict_f); command::add("edict", ED_PrintEdict_f);
Cmd_AddCommand ("edicts", ED_PrintEdicts); command::add("edicts", ED_PrintEdicts);
Cmd_AddCommand ("edictcount", ED_Count); command::add("edictcount", ED_Count);
Cmd_AddCommand ("profile", PR_Profile_f); command::add("profile", PR_Profile_f);
Cvar_RegisterVariable (&nomonsters); nomonsters.inscribe();
Cvar_RegisterVariable (&gamecfg); gamecfg.inscribe();
Cvar_RegisterVariable (&scratch1); scratch1.inscribe();
Cvar_RegisterVariable (&scratch2); scratch2.inscribe();
Cvar_RegisterVariable (&scratch3); scratch3.inscribe();
Cvar_RegisterVariable (&scratch4); scratch4.inscribe();
Cvar_RegisterVariable (&savedgamecfg); savedgamecfg.inscribe();
Cvar_RegisterVariable (&saved1); saved1.inscribe();
Cvar_RegisterVariable (&saved2); saved2.inscribe();
Cvar_RegisterVariable (&saved3); saved3.inscribe();
Cvar_RegisterVariable (&saved4); saved4.inscribe();
} }
+3 -2
View File
@@ -87,10 +87,11 @@ void ED_Free (edict_t *ed);
void ED_Print (edict_t *ed); void ED_Print (edict_t *ed);
void ED_Write (FILE *f, edict_t *ed); void ED_Write (FILE *f, edict_t *ed);
const char *ED_ParseEdict (const char *data, edict_t *ent);
void ED_ParseEdict(std::istringstream &ss, edict_t *ent);
void ED_WriteGlobals (FILE *f); void ED_WriteGlobals (FILE *f);
const char *ED_ParseGlobals (const char *data); void ED_ParseGlobals (std::istringstream &ss);
void ED_LoadFromFile (const char *data); void ED_LoadFromFile (const char *data);
+6 -6
View File
@@ -168,16 +168,16 @@ extern vec3_t listener_forward;
extern vec3_t listener_right; extern vec3_t listener_right;
extern vec3_t listener_up; extern vec3_t listener_up;
extern cvar_t sndspeed; extern convar sndspeed;
extern cvar_t snd_mixspeed; extern convar snd_mixspeed;
extern cvar_t snd_filterquality; extern convar snd_filterquality;
extern cvar_t sfxvolume; extern convar sfxvolume;
extern cvar_t loadas8bit; extern convar loadas8bit;
#define MAX_RAW_SAMPLES 8192 #define MAX_RAW_SAMPLES 8192
extern portable_samplepair_t s_rawsamples[MAX_RAW_SAMPLES]; extern portable_samplepair_t s_rawsamples[MAX_RAW_SAMPLES];
extern cvar_t bgmvolume; extern convar bgmvolume;
void S_LocalSound (const char *name); void S_LocalSound (const char *name);
sfxcache_t *S_LoadSound (sfx_t *s); sfxcache_t *S_LoadSound (sfx_t *s);
+8 -8
View File
@@ -75,15 +75,15 @@
#endif #endif
#endif #endif
#define Q_MAXCHAR ((char)0x7f) #define q_maxCHAR ((char)0x7f)
#define Q_MAXSHORT ((short)0x7fff) #define q_maxSHORT ((short)0x7fff)
#define Q_MAXINT ((int)0x7fffffff) #define q_maxINT ((int)0x7fffffff)
#define Q_MAXLONG ((int)0x7fffffff) #define q_maxLONG ((int)0x7fffffff)
#define Q_MINCHAR ((char)0x80) #define q_minCHAR ((char)0x80)
#define Q_MINSHORT ((short)0x8000) #define q_minSHORT ((short)0x8000)
#define Q_MININT ((int)0x80000000) #define q_minINT ((int)0x80000000)
#define Q_MINLONG ((int)0x80000000) #define q_minLONG ((int)0x80000000)
#ifndef COMPILE_TIME_ASSERT #ifndef COMPILE_TIME_ASSERT
#if defined(__cplusplus) #if defined(__cplusplus)
+7 -7
View File
@@ -211,7 +211,7 @@ typedef struct
#include "sys.hpp" #include "sys.hpp"
#include "zone.hpp" #include "zone.hpp"
#include "mathlib.hpp" #include "mathlib.hpp"
#include "cvar.hpp" #include "convar.hpp"
#include "protocol.hpp" #include "protocol.hpp"
#include "net.hpp" #include "net.hpp"
@@ -275,11 +275,11 @@ extern qboolean noclip_anglehack;
// //
extern quakeparms_t *host_parms; extern quakeparms_t *host_parms;
extern cvar_t sys_ticrate; extern convar sys_ticrate;
extern cvar_t sys_throttle; extern convar sys_throttle;
extern cvar_t sys_nostdout; extern convar sys_nostdout;
extern cvar_t developer; extern convar developer;
extern cvar_t max_edicts; //johnfitz extern convar max_edicts; //johnfitz
extern qboolean host_initialized; // true if into command execution extern qboolean host_initialized; // true if into command execution
extern double host_frametime; extern double host_frametime;
@@ -303,7 +303,7 @@ void Host_ServerFrame (void);
void Host_InitCommands (void); void Host_InitCommands (void);
void Host_Init (void); void Host_Init (void);
void Host_Shutdown(void); void Host_Shutdown(void);
void Host_Callback_Notify (cvar_t *var); /* callback function for CVAR_NOTIFY */ void Host_Callback_Notify (convar *var); /* callback function for CVAR_NOTIFY */
FUNC_NORETURN void Host_Error (const char *error, ...) FUNC_PRINTF(1,2); FUNC_NORETURN void Host_Error (const char *error, ...) FUNC_PRINTF(1,2);
FUNC_NORETURN void Host_EndGame (const char *message, ...) FUNC_PRINTF(1,2); FUNC_NORETURN void Host_EndGame (const char *message, ...) FUNC_PRINTF(1,2);
#ifdef __WATCOMC__ #ifdef __WATCOMC__
+2 -2
View File
@@ -24,8 +24,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "quakedef.hpp" #include "quakedef.hpp"
extern cvar_t r_drawflat, gl_overbright_models, gl_fullbrights, r_lerpmodels, r_lerpmove; //johnfitz extern convar r_drawflat, gl_overbright_models, gl_fullbrights, r_lerpmodels, r_lerpmove; //johnfitz
extern cvar_t scr_fov, cl_gun_fovscale; extern convar scr_fov, cl_gun_fovscale;
//up to 16 color translated skins //up to 16 color translated skins
gltexture_t *playertextures[MAX_SCOREBOARD]; //johnfitz -- changed to an array of pointers gltexture_t *playertextures[MAX_SCOREBOARD]; //johnfitz -- changed to an array of pointers
+2 -2
View File
@@ -24,8 +24,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "quakedef.hpp" #include "quakedef.hpp"
extern cvar_t gl_fullbrights, r_drawflat, gl_overbright, r_oldwater; //johnfitz extern convar gl_fullbrights, r_drawflat, gl_overbright, r_oldwater; //johnfitz
extern cvar_t gl_zfix; // QuakeSpasm z-fighting fix extern convar gl_zfix; // QuakeSpasm z-fighting fix
int gl_lightmap_format; int gl_lightmap_format;
int lightmap_bytes; int lightmap_bytes;
+10 -10
View File
@@ -39,8 +39,8 @@ static int r_numparticles;
static gltexture_t *particletexture, *particletexture1, *particletexture2, *particletexture3; //johnfitz static gltexture_t *particletexture, *particletexture1, *particletexture2, *particletexture3; //johnfitz
static float texturescalefactor; //johnfitz -- compensate for apparent size of different particle textures static float texturescalefactor; //johnfitz -- compensate for apparent size of different particle textures
cvar_t r_particles = {"r_particles","1", CVAR_ARCHIVE}; //johnfitz convar r_particles{"r_particles","1", {.archive = true}}; //johnfitz
cvar_t r_quadparticles = {"r_quadparticles","1", CVAR_ARCHIVE}; //johnfitz convar r_quadparticles{"r_quadparticles","1", {.archive = true}}; //johnfitz
/* /*
=============== ===============
@@ -57,7 +57,7 @@ int R_ParticleTextureLookup (int x, int y, int sharpness)
r = x * x + y * y; r = x * x + y * y;
r = r > 255 ? 255 : r; r = r > 255 ? 255 : r;
a = sharpness * (255 - r); a = sharpness * (255 - r);
a = q_min(a,255); a = std::min(a,255);
return a; return a;
} }
@@ -120,7 +120,7 @@ void R_InitParticleTextures (void)
R_SetParticleTexture_f -- johnfitz R_SetParticleTexture_f -- johnfitz
=============== ===============
*/ */
static void R_SetParticleTexture_f (cvar_t *var) static void R_SetParticleTexture_f (convar *var)
{ {
switch ((int)(r_particles.value)) switch ((int)(r_particles.value))
{ {
@@ -166,9 +166,9 @@ void R_InitParticles (void)
particles = (particle_t *) particles = (particle_t *)
Hunk_AllocName (r_numparticles * sizeof(particle_t), "particles"); Hunk_AllocName (r_numparticles * sizeof(particle_t), "particles");
Cvar_RegisterVariable (&r_particles); //johnfitz r_particles.inscribe(); //johnfitz
Cvar_SetCallback (&r_particles, R_SetParticleTexture_f); r_particles.set_callback(R_SetParticleTexture_f);
Cvar_RegisterVariable (&r_quadparticles); //johnfitz r_quadparticles.inscribe(); //johnfitz
R_InitParticleTextures (); //johnfitz R_InitParticleTextures (); //johnfitz
} }
@@ -722,7 +722,7 @@ void CL_RunParticles (void)
particle_t *p, *kill; particle_t *p, *kill;
int i; int i;
float time1, time2, time3, dvel, frametime, grav; float time1, time2, time3, dvel, frametime, grav;
extern cvar_t sv_gravity; extern convar sv_gravity;
frametime = cl.time - cl.oldtime; frametime = cl.time - cl.oldtime;
time3 = frametime * 15; time3 = frametime * 15;
@@ -829,7 +829,7 @@ void R_DrawParticles (void)
float scale; float scale;
vec3_t up, right, p_up, p_right, p_upright; //johnfitz -- p_ vectors vec3_t up, right, p_up, p_right, p_upright; //johnfitz -- p_ vectors
GLubyte color[4], *c; //johnfitz -- particle transparency GLubyte color[4], *c; //johnfitz -- particle transparency
extern cvar_t r_particles; //johnfitz extern convar r_particles; //johnfitz
//float alpha; //johnfitz -- particle transparency //float alpha; //johnfitz -- particle transparency
if (!r_particles.value) if (!r_particles.value)
@@ -949,7 +949,7 @@ void R_DrawParticles_ShowTris (void)
particle_t *p; particle_t *p;
float scale; float scale;
vec3_t up, right, p_up, p_right, p_upright; vec3_t up, right, p_up, p_right, p_upright;
extern cvar_t r_particles; extern convar r_particles;
if (!r_particles.value) if (!r_particles.value)
return; return;
+1 -1
View File
@@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "quakedef.hpp" #include "quakedef.hpp"
extern cvar_t gl_fullbrights, r_drawflat, gl_overbright, r_oldwater, r_oldskyleaf, r_showtris; //johnfitz extern convar gl_fullbrights, r_drawflat, gl_overbright, r_oldwater, r_oldskyleaf, r_showtris; //johnfitz
byte *SV_FatPVS (vec3_t org, qmodel_t *worldmodel); byte *SV_FatPVS (vec3_t org, qmodel_t *worldmodel);
+8 -8
View File
@@ -253,8 +253,8 @@ Sbar_Init -- johnfitz -- rewritten
*/ */
void Sbar_Init (void) void Sbar_Init (void)
{ {
Cmd_AddCommand ("+showscores", Sbar_ShowScores); command::add ("+showscores", Sbar_ShowScores);
Cmd_AddCommand ("-showscores", Sbar_DontShowScores); command::add ("-showscores", Sbar_DontShowScores);
Sbar_LoadPics (); Sbar_LoadPics ();
} }
@@ -388,7 +388,7 @@ void Sbar_DrawNum (int x, int y, int num, int digits, int color)
char *ptr; char *ptr;
int l, frame; int l, frame;
num = q_min(999,num); //johnfitz -- cap high values rather than truncating number num = std::min(999,num); //johnfitz -- cap high values rather than truncating number
l = Sbar_itoa (num, str); l = Sbar_itoa (num, str);
ptr = str; ptr = str;
@@ -640,7 +640,7 @@ void Sbar_DrawInventory (void)
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
val = cl.stats[STAT_SHELLS+i]; val = cl.stats[STAT_SHELLS+i];
val = (val < 0)? 0 : q_min(999,val);//johnfitz -- cap displayed value to 999 val = (val < 0)? 0 : std::min(999,val);//johnfitz -- cap displayed value to 999
sprintf (num, "%3i", val); sprintf (num, "%3i", val);
if (num[0] != ' ') if (num[0] != ' ')
Sbar_DrawCharacter ( (6*i+1)*8 + 2, -24, 18 + num[0] - '0'); Sbar_DrawCharacter ( (6*i+1)*8 + 2, -24, 18 + num[0] - '0');
@@ -754,7 +754,7 @@ void Sbar_DrawFrags (void)
Sbar_SortFrags (); Sbar_SortFrags ();
// draw the text // draw the text
numscores = q_min(scoreboardlines, 4); numscores = std::min(scoreboardlines, 4);
for (i = 0, x = 184; i<numscores; i++, x += 32) for (i = 0, x = 184; i<numscores; i++, x += 32)
{ {
@@ -1302,12 +1302,12 @@ void Sbar_IntermissionOverlay (void)
lsecrets = Sbar_IntermissionTextWidth (secrets, 0); lsecrets = Sbar_IntermissionTextWidth (secrets, 0);
lmonsters = Sbar_IntermissionTextWidth (monsters, 0); lmonsters = Sbar_IntermissionTextWidth (monsters, 0);
total = q_max (ltime, lsecrets); total = std::max (ltime, lsecrets);
total = q_max (lmonsters, total); total = std::max (lmonsters, total);
pic = Draw_CachePic ("gfx/inter.lmp"); pic = Draw_CachePic ("gfx/inter.lmp");
total += pic->width + 24; total += pic->width + 24;
total = q_min (320, total); total = std::min (320, total);
Draw_Pic (160 - total / 2, 56, pic); Draw_Pic (160 - total / 2, 56, pic);
pic = Draw_CachePic ("gfx/complete.lmp"); pic = Draw_CachePic ("gfx/complete.lmp");
+8 -8
View File
@@ -50,9 +50,9 @@ extern int clearnotify; // set to 0 whenever notify text is drawn
extern qboolean scr_disabled_for_loading; extern qboolean scr_disabled_for_loading;
extern qboolean scr_skipupdate; extern qboolean scr_skipupdate;
extern cvar_t scr_viewsize; extern convar scr_viewsize;
extern cvar_t scr_sbaralpha; //johnfitz extern convar scr_sbaralpha; //johnfitz
void SCR_UpdateWholeScreen (void); void SCR_UpdateWholeScreen (void);
@@ -70,12 +70,12 @@ typedef enum {
CANVAS_TOPRIGHT, CANVAS_TOPRIGHT,
CANVAS_INVALID = -1 CANVAS_INVALID = -1
} canvastype; } canvastype;
extern cvar_t scr_menuscale; extern convar scr_menuscale;
extern cvar_t scr_sbarscale; extern convar scr_sbarscale;
extern cvar_t scr_conwidth; extern convar scr_conwidth;
extern cvar_t scr_conscale; extern convar scr_conscale;
extern cvar_t scr_scale; extern convar scr_scale;
extern cvar_t scr_crosshairscale; extern convar scr_crosshairscale;
//johnfitz //johnfitz
extern int scr_tileclear_updates; //johnfitz extern int scr_tileclear_updates; //johnfitz
+6 -6
View File
@@ -189,12 +189,12 @@ typedef struct client_s
//============================================================================ //============================================================================
extern cvar_t teamplay; extern convar teamplay;
extern cvar_t skill; extern convar skill;
extern cvar_t deathmatch; extern convar deathmatch;
extern cvar_t coop; extern convar coop;
extern cvar_t fraglimit; extern convar fraglimit;
extern cvar_t timelimit; extern convar timelimit;
extern server_static_t svs; // persistant server info extern server_static_t svs; // persistant server info
extern server_t sv; // local server extern server_t sv; // local server
+135 -223
View File
@@ -29,10 +29,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "bgmusic.hpp" #include "bgmusic.hpp"
static void S_Play(void); static void S_Play(void);
static void S_PlayVol(void); static void S_PlayVol(void);
static void S_SoundList(void); static void S_SoundList(void);
static void S_Update_(void); static void S_Update_(void);
void S_StopAllSounds(qboolean clear); void S_StopAllSounds(qboolean clear);
static void S_StopAllSoundsC(void); static void S_StopAllSoundsC(void);
// ======================================================================= // =======================================================================
@@ -70,14 +75,14 @@ static sfx_t *ambient_sfx[NUM_AMBIENTS];
static qboolean sound_started = false; static qboolean sound_started = false;
cvar_t bgmvolume = {"bgmvolume", "1", CVAR_ARCHIVE}; convar bgmvolume = {"bgmvolume", "1", {.archive = true}};
cvar_t sfxvolume = {"volume", "0.7", CVAR_ARCHIVE}; convar sfxvolume = {"volume", "0.7", {.archive = true}};
cvar_t precache = {"precache", "1", CVAR_NONE}; convar precache = {"precache", "1"};
cvar_t loadas8bit = {"loadas8bit", "0", CVAR_NONE}; convar loadas8bit = {"loadas8bit", "0"};
cvar_t sndspeed = {"sndspeed", "11025", CVAR_NONE}; convar sndspeed = {"sndspeed", "11025"};
cvar_t snd_mixspeed = {"snd_mixspeed", "44100", CVAR_NONE}; convar snd_mixspeed = {"snd_mixspeed", "44100"};
#if defined(_WIN32) #if defined(_WIN32)
#define SND_FILTERQUALITY_DEFAULT "5" #define SND_FILTERQUALITY_DEFAULT "5"
@@ -85,21 +90,18 @@ cvar_t snd_mixspeed = {"snd_mixspeed", "44100", CVAR_NONE};
#define SND_FILTERQUALITY_DEFAULT "1" #define SND_FILTERQUALITY_DEFAULT "1"
#endif #endif
cvar_t snd_filterquality = {"snd_filterquality", SND_FILTERQUALITY_DEFAULT, convar snd_filterquality = {"snd_filterquality", SND_FILTERQUALITY_DEFAULT};
CVAR_NONE};
static cvar_t nosound = {"nosound", "0", CVAR_NONE}; static convar nosound = {"nosound", "0"};
static cvar_t ambient_level = {"ambient_level", "0.3", CVAR_NONE}; static convar ambient_level = {"ambient_level", "0.3"};
static cvar_t ambient_fade = {"ambient_fade", "100", CVAR_NONE}; static convar ambient_fade = {"ambient_fade", "100"};
static cvar_t snd_noextraupdate = {"snd_noextraupdate", "0", CVAR_NONE}; static convar snd_noextraupdate = {"snd_noextraupdate", "0"};
static cvar_t snd_show = {"snd_show", "0", CVAR_NONE}; static convar snd_show = {"snd_show", "0"};
static cvar_t _snd_mixahead = {"_snd_mixahead", "0.1", CVAR_ARCHIVE}; static convar _snd_mixahead = {"_snd_mixahead", "0.1", {.archive = true}};
static void S_SoundInfo_f (void) static void S_SoundInfo_f(void) {
{ if (!sound_started || !shm) {
if (!sound_started || !shm)
{
Con_Printf("sound system not started\n"); Con_Printf("sound system not started\n");
return; return;
} }
@@ -114,17 +116,14 @@ static void S_SoundInfo_f (void)
} }
static void SND_Callback_sfxvolume (cvar_t *var) static void SND_Callback_sfxvolume(convar *var) {
{
SND_InitScaletable(); SND_InitScaletable();
} }
static void SND_Callback_snd_filterquality (cvar_t *var) static void SND_Callback_snd_filterquality(convar *var) {
{ if (snd_filterquality.value < 1 || snd_filterquality.value > 5) {
if (snd_filterquality.value < 1 || snd_filterquality.value > 5)
{
Con_Printf("snd_filterquality must be between 1 and 5\n"); Con_Printf("snd_filterquality must be between 1 and 5\n");
Cvar_SetQuick (&snd_filterquality, SND_FILTERQUALITY_DEFAULT); snd_filterquality.set(SND_FILTERQUALITY_DEFAULT);
} }
} }
@@ -133,19 +132,15 @@ static void SND_Callback_snd_filterquality (cvar_t *var)
S_Startup S_Startup
================ ================
*/ */
void S_Startup (void) void S_Startup(void) {
{
if (!snd_initialized) if (!snd_initialized)
return; return;
sound_started = SNDDMA_Init(&sn); sound_started = SNDDMA_Init(&sn);
if (!sound_started) if (!sound_started) {
{
Con_Printf("Failed initializing sound\n"); Con_Printf("Failed initializing sound\n");
} } else {
else
{
Con_Printf("Audio: %d bit, %s, %d Hz\n", shm->samplebits, Con_Printf("Audio: %d bit, %s, %d Hz\n", shm->samplebits,
(shm->channels == 2) ? "stereo" : "mono", shm->speed); (shm->channels == 2) ? "stereo" : "mono", shm->speed);
} }
@@ -157,61 +152,56 @@ void S_Startup (void)
S_Init S_Init
================ ================
*/ */
void S_Init (void) void S_Init(void) {
{
int i; int i;
if (snd_initialized) if (snd_initialized) {
{
Con_Printf("Sound is already initialized\n"); Con_Printf("Sound is already initialized\n");
return; return;
} }
Cvar_RegisterVariable(&nosound); nosound.inscribe();
Cvar_RegisterVariable(&sfxvolume); sfxvolume.inscribe();
Cvar_RegisterVariable(&precache); precache.inscribe();
Cvar_RegisterVariable(&loadas8bit); loadas8bit.inscribe();
Cvar_RegisterVariable(&bgmvolume); bgmvolume.inscribe();
Cvar_RegisterVariable(&ambient_level); ambient_level.inscribe();
Cvar_RegisterVariable(&ambient_fade); ambient_fade.inscribe();
Cvar_RegisterVariable(&snd_noextraupdate); snd_noextraupdate.inscribe();
Cvar_RegisterVariable(&snd_show); snd_show.inscribe();
Cvar_RegisterVariable(&_snd_mixahead); _snd_mixahead.inscribe();
Cvar_RegisterVariable(&sndspeed); sndspeed.inscribe();
Cvar_RegisterVariable(&snd_mixspeed); snd_mixspeed.inscribe();
Cvar_RegisterVariable(&snd_filterquality); snd_filterquality.inscribe();
if (safemode || COM_CheckParm("-nosound")) if (safemode || COM_CheckParm("-nosound"))
return; return;
Con_Printf("\nSound Initialization\n"); Con_Printf("\nSound Initialization\n");
Cmd_AddCommand("play", S_Play); command::add("play", S_Play);
Cmd_AddCommand("playvol", S_PlayVol); command::add("playvol", S_PlayVol);
Cmd_AddCommand("stopsound", S_StopAllSoundsC); command::add("stopsound", S_StopAllSoundsC);
Cmd_AddCommand("soundlist", S_SoundList); command::add("soundlist", S_SoundList);
Cmd_AddCommand("soundinfo", S_SoundInfo_f); command::add("soundinfo", S_SoundInfo_f);
i = COM_CheckParm("-sndspeed"); i = COM_CheckParm("-sndspeed");
if (i && i < com_argc-1) if (i && i < com_argc - 1) {
{ sndspeed.set(com_argv[i + 1]);
Cvar_SetQuick (&sndspeed, com_argv[i + 1]);
} }
i = COM_CheckParm("-mixspeed"); i = COM_CheckParm("-mixspeed");
if (i && i < com_argc-1) if (i && i < com_argc - 1) {
{ snd_mixspeed.set(com_argv[i + 1]);
Cvar_SetQuick (&snd_mixspeed, com_argv[i + 1]);
} }
if (host_parms->memsize < 0x800000) if (host_parms->memsize < 0x800000) {
{ loadas8bit.set("1");
Cvar_SetQuick (&loadas8bit, "1");
Con_Printf("loading all sounds as 8bit\n"); Con_Printf("loading all sounds as 8bit\n");
} }
Cvar_SetCallback(&sfxvolume, SND_Callback_sfxvolume); sfxvolume.set_callback(SND_Callback_sfxvolume);
Cvar_SetCallback(&snd_filterquality, &SND_Callback_snd_filterquality); snd_filterquality.set_callback(&SND_Callback_snd_filterquality);
SND_InitScaletable(); SND_InitScaletable();
@@ -240,8 +230,7 @@ void S_Init (void)
// ======================================================================= // =======================================================================
// Shutdown sound engine // Shutdown sound engine
// ======================================================================= // =======================================================================
void S_Shutdown (void) void S_Shutdown(void) {
{
if (!sound_started) if (!sound_started)
return; return;
@@ -265,8 +254,7 @@ S_FindName
================== ==================
*/ */
static sfx_t *S_FindName (const char *name) static sfx_t *S_FindName(const char *name) {
{
int i; int i;
sfx_t *sfx; sfx_t *sfx;
@@ -277,10 +265,8 @@ static sfx_t *S_FindName (const char *name)
Sys_Error("Sound name too long: %s", name); Sys_Error("Sound name too long: %s", name);
// see if already loaded // see if already loaded
for (i = 0; i < num_sfx; i++) for (i = 0; i < num_sfx; i++) {
{ if (!strcmp(known_sfx[i].name, name)) {
if (!strcmp(known_sfx[i].name, name))
{
return &known_sfx[i]; return &known_sfx[i];
} }
} }
@@ -303,8 +289,7 @@ S_TouchSound
================== ==================
*/ */
void S_TouchSound (const char *name) void S_TouchSound(const char *name) {
{
sfx_t *sfx; sfx_t *sfx;
if (!sound_started) if (!sound_started)
@@ -320,8 +305,7 @@ S_PrecacheSound
================== ==================
*/ */
sfx_t *S_PrecacheSound (const char *name) sfx_t *S_PrecacheSound(const char *name) {
{
sfx_t *sfx; sfx_t *sfx;
if (!sound_started || nosound.value) if (!sound_started || nosound.value)
@@ -346,8 +330,7 @@ SND_PickChannel
picks a channel based on priorities, empty slots, number of channels picks a channel based on priorities, empty slots, number of channels
================= =================
*/ */
channel_t *SND_PickChannel (int entnum, int entchannel) channel_t *SND_PickChannel(int entnum, int entchannel) {
{
int ch_idx; int ch_idx;
int first_to_die; int first_to_die;
int life_left; int life_left;
@@ -355,12 +338,11 @@ channel_t *SND_PickChannel (int entnum, int entchannel)
// Check for replacement sound, or find the best one to replace // Check for replacement sound, or find the best one to replace
first_to_die = -1; first_to_die = -1;
life_left = 0x7fffffff; life_left = 0x7fffffff;
for (ch_idx = NUM_AMBIENTS; ch_idx < NUM_AMBIENTS + MAX_DYNAMIC_CHANNELS; ch_idx++) for (ch_idx = NUM_AMBIENTS; ch_idx < NUM_AMBIENTS + MAX_DYNAMIC_CHANNELS; ch_idx++) {
{
if (entchannel != 0 // channel 0 never overrides if (entchannel != 0 // channel 0 never overrides
&& snd_channels[ch_idx].entnum == entnum && snd_channels[ch_idx].entnum == entnum
&& (snd_channels[ch_idx].entchannel == entchannel || entchannel == -1) ) && (snd_channels[ch_idx].entchannel == entchannel || entchannel == -1)) {
{ // always override sound from same entity // always override sound from same entity
first_to_die = ch_idx; first_to_die = ch_idx;
break; break;
} }
@@ -369,8 +351,7 @@ channel_t *SND_PickChannel (int entnum, int entchannel)
if (snd_channels[ch_idx].entnum == cl.viewentity && entnum != cl.viewentity && snd_channels[ch_idx].sfx) if (snd_channels[ch_idx].entnum == cl.viewentity && entnum != cl.viewentity && snd_channels[ch_idx].sfx)
continue; continue;
if (snd_channels[ch_idx].end - paintedtime < life_left) if (snd_channels[ch_idx].end - paintedtime < life_left) {
{
life_left = snd_channels[ch_idx].end - paintedtime; life_left = snd_channels[ch_idx].end - paintedtime;
first_to_die = ch_idx; first_to_die = ch_idx;
} }
@@ -392,16 +373,14 @@ SND_Spatialize
spatializes a channel spatializes a channel
================= =================
*/ */
void SND_Spatialize (channel_t *ch) void SND_Spatialize(channel_t *ch) {
{
vec_t dot; vec_t dot;
vec_t dist; vec_t dist;
vec_t lscale, rscale, scale; vec_t lscale, rscale, scale;
vec3_t source_vec; vec3_t source_vec;
// anything coming from the view entity will always be full volume // anything coming from the view entity will always be full volume
if (ch->entnum == cl.viewentity) if (ch->entnum == cl.viewentity) {
{
ch->leftvol = ch->master_vol; ch->leftvol = ch->master_vol;
ch->rightvol = ch->master_vol; ch->rightvol = ch->master_vol;
return; return;
@@ -412,13 +391,10 @@ void SND_Spatialize (channel_t *ch)
dist = VectorNormalize(source_vec) * ch->dist_mult; dist = VectorNormalize(source_vec) * ch->dist_mult;
dot = DotProduct(listener_right, source_vec); dot = DotProduct(listener_right, source_vec);
if (shm->channels == 1) if (shm->channels == 1) {
{
rscale = 1.0; rscale = 1.0;
lscale = 1.0; lscale = 1.0;
} } else {
else
{
rscale = 1.0 + dot; rscale = 1.0 + dot;
lscale = 1.0 - dot; lscale = 1.0 - dot;
} }
@@ -440,8 +416,7 @@ void SND_Spatialize (channel_t *ch)
// Start a sound effect // Start a sound effect
// ======================================================================= // =======================================================================
void S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation) void S_StartSound(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation) {
{
channel_t *target_chan, *check; channel_t *target_chan, *check;
sfxcache_t *sc; sfxcache_t *sc;
int ch_idx; int ch_idx;
@@ -475,8 +450,7 @@ void S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float
// new channel // new channel
sc = S_LoadSound(sfx); sc = S_LoadSound(sfx);
if (!sc) if (!sc) {
{
target_chan->sfx = NULL; target_chan->sfx = NULL;
return; // couldn't load the sound's data return; // couldn't load the sound's data
} }
@@ -488,12 +462,10 @@ void S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float
// if an identical sound has also been started this frame, offset the pos // if an identical sound has also been started this frame, offset the pos
// a bit to keep it from just making the first one louder // a bit to keep it from just making the first one louder
check = &snd_channels[NUM_AMBIENTS]; check = &snd_channels[NUM_AMBIENTS];
for (ch_idx = NUM_AMBIENTS; ch_idx < NUM_AMBIENTS + MAX_DYNAMIC_CHANNELS; ch_idx++, check++) for (ch_idx = NUM_AMBIENTS; ch_idx < NUM_AMBIENTS + MAX_DYNAMIC_CHANNELS; ch_idx++, check++) {
{
if (check == target_chan) if (check == target_chan)
continue; continue;
if (check->sfx == sfx && !check->pos) if (check->sfx == sfx && !check->pos) {
{
/* /*
skip = rand () % (int)(0.1 * shm->speed); skip = rand () % (int)(0.1 * shm->speed);
if (skip >= target_chan->end) if (skip >= target_chan->end)
@@ -512,15 +484,12 @@ void S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float
} }
} }
void S_StopSound (int entnum, int entchannel) void S_StopSound(int entnum, int entchannel) {
{
int i; int i;
for (i = 0; i < MAX_DYNAMIC_CHANNELS; i++) for (i = 0; i < MAX_DYNAMIC_CHANNELS; i++) {
{
if (snd_channels[i].entnum == entnum if (snd_channels[i].entnum == entnum
&& snd_channels[i].entchannel == entchannel) && snd_channels[i].entchannel == entchannel) {
{
snd_channels[i].end = 0; snd_channels[i].end = 0;
snd_channels[i].sfx = NULL; snd_channels[i].sfx = NULL;
return; return;
@@ -528,8 +497,7 @@ void S_StopSound (int entnum, int entchannel)
} }
} }
void S_StopAllSounds (qboolean clear) void S_StopAllSounds(qboolean clear) {
{
int i; int i;
if (!sound_started) if (!sound_started)
@@ -537,8 +505,7 @@ void S_StopAllSounds (qboolean clear)
total_channels = MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS; // no statics total_channels = MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS; // no statics
for (i = 0; i < MAX_CHANNELS; i++) for (i = 0; i < MAX_CHANNELS; i++) {
{
if (snd_channels[i].sfx) if (snd_channels[i].sfx)
snd_channels[i].sfx = NULL; snd_channels[i].sfx = NULL;
} }
@@ -549,13 +516,11 @@ void S_StopAllSounds (qboolean clear)
S_ClearBuffer(); S_ClearBuffer();
} }
static void S_StopAllSoundsC (void) static void S_StopAllSoundsC(void) {
{
S_StopAllSounds(true); S_StopAllSounds(true);
} }
void S_ClearBuffer (void) void S_ClearBuffer(void) {
{
int clear; int clear;
if (!sound_started || !shm) if (!sound_started || !shm)
@@ -583,16 +548,14 @@ void S_ClearBuffer (void)
S_StaticSound S_StaticSound
================= =================
*/ */
void S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation) void S_StaticSound(sfx_t *sfx, vec3_t origin, float vol, float attenuation) {
{
channel_t *ss; channel_t *ss;
sfxcache_t *sc; sfxcache_t *sc;
if (!sfx) if (!sfx)
return; return;
if (total_channels == MAX_CHANNELS) if (total_channels == MAX_CHANNELS) {
{
Con_Printf("total_channels == MAX_CHANNELS\n"); Con_Printf("total_channels == MAX_CHANNELS\n");
return; return;
} }
@@ -604,8 +567,7 @@ void S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation)
if (!sc) if (!sc)
return; return;
if (sc->loopstart == -1) if (sc->loopstart == -1) {
{
Con_Printf("Sound %s not looped\n", sfx->name); Con_Printf("Sound %s not looped\n", sfx->name);
return; return;
} }
@@ -627,8 +589,7 @@ void S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation)
S_UpdateAmbientSounds S_UpdateAmbientSounds
=================== ===================
*/ */
static void S_UpdateAmbientSounds (void) static void S_UpdateAmbientSounds(void) {
{
mleaf_t *l; mleaf_t *l;
int vol, ambient_channel; int vol, ambient_channel;
channel_t *chan; channel_t *chan;
@@ -641,15 +602,13 @@ static void S_UpdateAmbientSounds (void)
return; return;
l = Mod_PointInLeaf(listener_origin, cl.worldmodel); l = Mod_PointInLeaf(listener_origin, cl.worldmodel);
if (!l || !ambient_level.value) if (!l || !ambient_level.value) {
{
for (ambient_channel = 0; ambient_channel < NUM_AMBIENTS; ambient_channel++) for (ambient_channel = 0; ambient_channel < NUM_AMBIENTS; ambient_channel++)
snd_channels[ambient_channel].sfx = NULL; snd_channels[ambient_channel].sfx = NULL;
return; return;
} }
for (ambient_channel = 0; ambient_channel < NUM_AMBIENTS; ambient_channel++) for (ambient_channel = 0; ambient_channel < NUM_AMBIENTS; ambient_channel++) {
{
chan = &snd_channels[ambient_channel]; chan = &snd_channels[ambient_channel];
chan->sfx = ambient_sfx[ambient_channel]; chan->sfx = ambient_sfx[ambient_channel];
@@ -658,14 +617,11 @@ static void S_UpdateAmbientSounds (void)
vol = 0; vol = 0;
// don't adjust volume too fast // don't adjust volume too fast
if (chan->master_vol < vol) if (chan->master_vol < vol) {
{
chan->master_vol += (int) (host_frametime * ambient_fade.value); chan->master_vol += (int) (host_frametime * ambient_fade.value);
if (chan->master_vol > vol) if (chan->master_vol > vol)
chan->master_vol = vol; chan->master_vol = vol;
} } else if (chan->master_vol > vol) {
else if (chan->master_vol > vol)
{
chan->master_vol -= (int) (host_frametime * ambient_fade.value); chan->master_vol -= (int) (host_frametime * ambient_fade.value);
if (chan->master_vol < vol) if (chan->master_vol < vol)
chan->master_vol = vol; chan->master_vol = vol;
@@ -686,8 +642,7 @@ Expects data in signed 16 bit, or unsigned
8 bit format. 8 bit format.
=================== ===================
*/ */
void S_RawSamples (int samples, int rate, int width, int channels, byte *data, float volume) void S_RawSamples(int samples, int rate, int width, int channels, byte *data, float volume) {
{
int i; int i;
int src, dst; int src, dst;
float scale; float scale;
@@ -699,10 +654,8 @@ void S_RawSamples (int samples, int rate, int width, int channels, byte *data, f
scale = (float) rate / shm->speed; scale = (float) rate / shm->speed;
intVolume = (int) (256 * volume); intVolume = (int) (256 * volume);
if (channels == 2 && width == 2) if (channels == 2 && width == 2) {
{ for (i = 0; ; i++) {
for (i = 0; ; i++)
{
src = i * scale; src = i * scale;
if (src >= samples) if (src >= samples)
break; break;
@@ -711,11 +664,8 @@ void S_RawSamples (int samples, int rate, int width, int channels, byte *data, f
s_rawsamples[dst].left = ((short *) data)[src * 2] * intVolume; s_rawsamples[dst].left = ((short *) data)[src * 2] * intVolume;
s_rawsamples[dst].right = ((short *) data)[src * 2 + 1] * intVolume; s_rawsamples[dst].right = ((short *) data)[src * 2 + 1] * intVolume;
} }
} } else if (channels == 1 && width == 2) {
else if (channels == 1 && width == 2) for (i = 0; ; i++) {
{
for (i = 0; ; i++)
{
src = i * scale; src = i * scale;
if (src >= samples) if (src >= samples)
break; break;
@@ -724,13 +674,10 @@ void S_RawSamples (int samples, int rate, int width, int channels, byte *data, f
s_rawsamples[dst].left = ((short *) data)[src] * intVolume; s_rawsamples[dst].left = ((short *) data)[src] * intVolume;
s_rawsamples[dst].right = ((short *) data)[src] * intVolume; s_rawsamples[dst].right = ((short *) data)[src] * intVolume;
} }
} } else if (channels == 2 && width == 1) {
else if (channels == 2 && width == 1)
{
intVolume *= 256; intVolume *= 256;
for (i = 0; ; i++) for (i = 0; ; i++) {
{
src = i * scale; src = i * scale;
if (src >= samples) if (src >= samples)
break; break;
@@ -741,13 +688,10 @@ void S_RawSamples (int samples, int rate, int width, int channels, byte *data, f
s_rawsamples[dst].left = (((byte *) data)[src * 2] - 128) * intVolume; s_rawsamples[dst].left = (((byte *) data)[src * 2] - 128) * intVolume;
s_rawsamples[dst].right = (((byte *) data)[src * 2 + 1] - 128) * intVolume; s_rawsamples[dst].right = (((byte *) data)[src * 2 + 1] - 128) * intVolume;
} }
} } else if (channels == 1 && width == 1) {
else if (channels == 1 && width == 1)
{
intVolume *= 256; intVolume *= 256;
for (i = 0; ; i++) for (i = 0; ; i++) {
{
src = i * scale; src = i * scale;
if (src >= samples) if (src >= samples)
break; break;
@@ -768,8 +712,7 @@ S_Update
Called once each time through the main loop Called once each time through the main loop
============ ============
*/ */
void S_Update (vec3_t origin, vec3_t forward, vec3_t right, vec3_t up) void S_Update(vec3_t origin, vec3_t forward, vec3_t right, vec3_t up) {
{
int i, j; int i, j;
int total; int total;
channel_t *ch; channel_t *ch;
@@ -790,8 +733,7 @@ void S_Update (vec3_t origin, vec3_t forward, vec3_t right, vec3_t up)
// update spatialization for static and dynamic sounds // update spatialization for static and dynamic sounds
ch = snd_channels + NUM_AMBIENTS; ch = snd_channels + NUM_AMBIENTS;
for (i = NUM_AMBIENTS; i < total_channels; i++, ch++) for (i = NUM_AMBIENTS; i < total_channels; i++, ch++) {
{
if (!ch->sfx) if (!ch->sfx)
continue; continue;
SND_Spatialize(ch); // respatialize channel SND_Spatialize(ch); // respatialize channel
@@ -801,11 +743,9 @@ void S_Update (vec3_t origin, vec3_t forward, vec3_t right, vec3_t up)
// try to combine static sounds with a previous channel of the same // try to combine static sounds with a previous channel of the same
// sound effect so we don't mix five torches every frame // sound effect so we don't mix five torches every frame
if (i >= MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS) if (i >= MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS) {
{
// see if it can just use the last one // see if it can just use the last one
if (combine && combine->sfx == ch->sfx) if (combine && combine->sfx == ch->sfx) {
{
combine->leftvol += ch->leftvol; combine->leftvol += ch->leftvol;
combine->rightvol += ch->rightvol; combine->rightvol += ch->rightvol;
ch->leftvol = ch->rightvol = 0; ch->leftvol = ch->rightvol = 0;
@@ -813,20 +753,15 @@ void S_Update (vec3_t origin, vec3_t forward, vec3_t right, vec3_t up)
} }
// search for one // search for one
combine = snd_channels + MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS; combine = snd_channels + MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS;
for (j = MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS; j < i; j++, combine++) for (j = MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS; j < i; j++, combine++) {
{
if (combine->sfx == ch->sfx) if (combine->sfx == ch->sfx)
break; break;
} }
if (j == total_channels) if (j == total_channels) {
{
combine = NULL; combine = NULL;
} } else {
else if (combine != ch) {
{
if (combine != ch)
{
combine->leftvol += ch->leftvol; combine->leftvol += ch->leftvol;
combine->rightvol += ch->rightvol; combine->rightvol += ch->rightvol;
ch->leftvol = ch->rightvol = 0; ch->leftvol = ch->rightvol = 0;
@@ -839,14 +774,11 @@ void S_Update (vec3_t origin, vec3_t forward, vec3_t right, vec3_t up)
// //
// debugging output // debugging output
// //
if (snd_show.value) if (snd_show.value) {
{
total = 0; total = 0;
ch = snd_channels; ch = snd_channels;
for (i = 0; i < total_channels; i++, ch++) for (i = 0; i < total_channels; i++, ch++) {
{ if (ch->sfx && (ch->leftvol || ch->rightvol)) {
if (ch->sfx && (ch->leftvol || ch->rightvol) )
{
// Con_Printf ("%3i %3i %s\n", ch->leftvol, ch->rightvol, ch->sfx->name); // Con_Printf ("%3i %3i %s\n", ch->leftvol, ch->rightvol, ch->sfx->name);
total++; total++;
} }
@@ -862,8 +794,7 @@ void S_Update (vec3_t origin, vec3_t forward, vec3_t right, vec3_t up)
S_Update_(); S_Update_();
} }
static void GetSoundtime (void) static void GetSoundtime(void) {
{
int samplepos; int samplepos;
static int buffers; static int buffers;
static int oldsamplepos; static int oldsamplepos;
@@ -875,12 +806,11 @@ static void GetSoundtime (void)
// calls to S_Update. Oh well. // calls to S_Update. Oh well.
samplepos = SNDDMA_GetDMAPos(); samplepos = SNDDMA_GetDMAPos();
if (samplepos < oldsamplepos) if (samplepos < oldsamplepos) {
{
buffers++; // buffer wrapped buffers++; // buffer wrapped
if (paintedtime > 0x40000000) if (paintedtime > 0x40000000) {
{ // time to chop things off to avoid 32 bit limits // time to chop things off to avoid 32 bit limits
buffers = 0; buffers = 0;
paintedtime = fullsamples; paintedtime = fullsamples;
S_StopAllSounds(true); S_StopAllSounds(true);
@@ -891,15 +821,13 @@ static void GetSoundtime (void)
soundtime = buffers * fullsamples + samplepos / shm->channels; soundtime = buffers * fullsamples + samplepos / shm->channels;
} }
void S_ExtraUpdate (void) void S_ExtraUpdate(void) {
{
if (snd_noextraupdate.value) if (snd_noextraupdate.value)
return; // don't pollute timings return; // don't pollute timings
S_Update_(); S_Update_();
} }
static void S_Update_ (void) static void S_Update_(void) {
{
unsigned int endtime; unsigned int endtime;
int samps; int samps;
@@ -914,8 +842,7 @@ static void S_Update_ (void)
GetSoundtime(); GetSoundtime();
// check to make sure that we haven't overshot // check to make sure that we haven't overshot
if (paintedtime < soundtime) if (paintedtime < soundtime) {
{
// Con_Printf ("S_Update_ : overflow\n"); // Con_Printf ("S_Update_ : overflow\n");
paintedtime = soundtime; paintedtime = soundtime;
} }
@@ -923,15 +850,14 @@ static void S_Update_ (void)
// mix ahead of current position // mix ahead of current position
endtime = soundtime + (unsigned int) (_snd_mixahead.value * shm->speed); endtime = soundtime + (unsigned int) (_snd_mixahead.value * shm->speed);
samps = shm->samples >> (shm->channels - 1); samps = shm->samples >> (shm->channels - 1);
endtime = q_min(endtime, (unsigned int)(soundtime + samps)); endtime = std::min(endtime, (unsigned int)(soundtime + samps));
S_PaintChannels(endtime); S_PaintChannels(endtime);
SNDDMA_Submit(); SNDDMA_Submit();
} }
void S_BlockSound (void) void S_BlockSound(void) {
{
/* FIXME: do we really need the blocking at the /* FIXME: do we really need the blocking at the
* driver level? * driver level?
*/ */
@@ -944,8 +870,7 @@ void S_BlockSound (void)
} }
} }
void S_UnblockSound (void) void S_UnblockSound(void) {
{
if (!sound_started || !snd_blocked) if (!sound_started || !snd_blocked)
return; return;
if (snd_blocked == 1) /* --snd_blocked == 0 */ if (snd_blocked == 1) /* --snd_blocked == 0 */
@@ -964,19 +889,16 @@ console functions
=============================================================================== ===============================================================================
*/ */
static void S_Play (void) static void S_Play(void) {
{
static int hash = 345; static int hash = 345;
int i; int i;
char name[256]; char name[256];
sfx_t *sfx; sfx_t *sfx;
i = 1; i = 1;
while (i < Cmd_Argc()) while (i < command::argc()) {
{ q_strlcpy(name, command::argv(i)->c_str(), sizeof(name));
q_strlcpy(name, Cmd_Argv(i), sizeof(name)); if (!strrchr(command::argv(i)->c_str(), '.')) {
if (!strrchr(Cmd_Argv(i), '.'))
{
q_strlcat(name, ".wav", sizeof(name)); q_strlcat(name, ".wav", sizeof(name));
} }
sfx = S_PrecacheSound(name); sfx = S_PrecacheSound(name);
@@ -985,8 +907,7 @@ static void S_Play (void)
} }
} }
static void S_PlayVol (void) static void S_PlayVol(void) {
{
static int hash = 543; static int hash = 543;
int i; int i;
float vol; float vol;
@@ -994,30 +915,26 @@ static void S_PlayVol (void)
sfx_t *sfx; sfx_t *sfx;
i = 1; i = 1;
while (i < Cmd_Argc()) while (i < command::argc()) {
{ q_strlcpy(name, command::argv(i)->c_str(), sizeof(name));
q_strlcpy(name, Cmd_Argv(i), sizeof(name)); if (!strrchr(command::argv(i)->c_str(), '.')) {
if (!strrchr(Cmd_Argv(i), '.'))
{
q_strlcat(name, ".wav", sizeof(name)); q_strlcat(name, ".wav", sizeof(name));
} }
sfx = S_PrecacheSound(name); sfx = S_PrecacheSound(name);
vol = atof(Cmd_Argv(i + 1)); vol = atof(command::argv(i + 1).value_or("").c_str());
S_StartSound(hash++, 0, sfx, listener_origin, vol, 1.0); S_StartSound(hash++, 0, sfx, listener_origin, vol, 1.0);
i += 2; i += 2;
} }
} }
static void S_SoundList (void) static void S_SoundList(void) {
{
int i; int i;
sfx_t *sfx; sfx_t *sfx;
sfxcache_t *sc; sfxcache_t *sc;
int size, total; int size, total;
total = 0; total = 0;
for (sfx = known_sfx, i = 0; i < num_sfx; i++, sfx++) for (sfx = known_sfx, i = 0; i < num_sfx; i++, sfx++) {
{
sc = (sfxcache_t *) Cache_Check(&sfx->cache); sc = (sfxcache_t *) Cache_Check(&sfx->cache);
if (!sc) if (!sc)
continue; continue;
@@ -1033,8 +950,7 @@ static void S_SoundList (void)
} }
void S_LocalSound (const char *name) void S_LocalSound(const char *name) {
{
sfx_t *sfx; sfx_t *sfx;
if (nosound.value) if (nosound.value)
@@ -1043,8 +959,7 @@ void S_LocalSound (const char *name)
return; return;
sfx = S_PrecacheSound(name); sfx = S_PrecacheSound(name);
if (!sfx) if (!sfx) {
{
Con_Printf("S_LocalSound: can't cache %s\n", name); Con_Printf("S_LocalSound: can't cache %s\n", name);
return; return;
} }
@@ -1052,14 +967,11 @@ void S_LocalSound (const char *name)
} }
void S_ClearPrecache (void) void S_ClearPrecache(void) {
{
} }
void S_BeginPrecaching (void) void S_BeginPrecaching(void) {
{
} }
void S_EndPrecaching (void) void S_EndPrecaching(void) {
{
} }
+1 -1
View File
@@ -183,7 +183,7 @@ static int mp3_decode(snd_stream_t *stream, byte *buf, int len)
do do
{ {
x = (p->Synth.pcm.length - p->cursamp) * stream->info.channels; x = (p->Synth.pcm.length - p->cursamp) * stream->info.channels;
donow = q_min(len, x); donow = std::min(len, x);
i = 0; i = 0;
while (i < donow) while (i < donow)
{ {
+35 -35
View File
@@ -44,13 +44,13 @@ void SV_Protocol_f (void)
{ {
int i; int i;
switch (Cmd_Argc()) switch (command::argc())
{ {
case 1: case 1:
Con_Printf ("\"sv_protocol\" is \"%i\"\n", sv_protocol); Con_Printf ("\"sv_protocol\" is \"%i\"\n", sv_protocol);
break; break;
case 2: case 2:
i = atoi(Cmd_Argv(1)); i = atoi(command::argv(1)->c_str());
if (i != PROTOCOL_NETQUAKE && i != PROTOCOL_FITZQUAKE && i != PROTOCOL_RMQ) if (i != PROTOCOL_NETQUAKE && i != PROTOCOL_FITZQUAKE && i != PROTOCOL_RMQ)
Con_Printf ("sv_protocol must be %i or %i or %i\n", PROTOCOL_NETQUAKE, PROTOCOL_FITZQUAKE, PROTOCOL_RMQ); Con_Printf ("sv_protocol must be %i or %i or %i\n", PROTOCOL_NETQUAKE, PROTOCOL_FITZQUAKE, PROTOCOL_RMQ);
else else
@@ -75,38 +75,38 @@ void SV_Init (void)
{ {
int i; int i;
const char *p; const char *p;
extern cvar_t sv_maxvelocity; extern convar sv_maxvelocity;
extern cvar_t sv_gravity; extern convar sv_gravity;
extern cvar_t sv_nostep; extern convar sv_nostep;
extern cvar_t sv_freezenonclients; extern convar sv_freezenonclients;
extern cvar_t sv_friction; extern convar sv_friction;
extern cvar_t sv_edgefriction; extern convar sv_edgefriction;
extern cvar_t sv_stopspeed; extern convar sv_stopspeed;
extern cvar_t sv_maxspeed; extern convar sv_maxspeed;
extern cvar_t sv_accelerate; extern convar sv_accelerate;
extern cvar_t sv_idealpitchscale; extern convar sv_idealpitchscale;
extern cvar_t sv_aim; extern convar sv_aim;
extern cvar_t sv_altnoclip; //johnfitz extern convar sv_altnoclip; //johnfitz
sv.edicts = NULL; // ericw -- sv.edicts switched to use malloc() sv.edicts = NULL; // ericw -- sv.edicts switched to use malloc()
Cvar_RegisterVariable (&sv_maxvelocity); sv_maxvelocity.inscribe();
Cvar_RegisterVariable (&sv_gravity); sv_gravity.inscribe();
Cvar_RegisterVariable (&sv_friction); sv_friction.inscribe();
Cvar_SetCallback (&sv_gravity, Host_Callback_Notify); sv_gravity.set_callback(Host_Callback_Notify);
Cvar_SetCallback (&sv_friction, Host_Callback_Notify); sv_friction.set_callback(Host_Callback_Notify);
Cvar_RegisterVariable (&sv_edgefriction); sv_edgefriction.inscribe();
Cvar_RegisterVariable (&sv_stopspeed); sv_stopspeed.inscribe();
Cvar_RegisterVariable (&sv_maxspeed); sv_maxspeed.inscribe();
Cvar_SetCallback (&sv_maxspeed, Host_Callback_Notify); sv_maxspeed.set_callback(Host_Callback_Notify);
Cvar_RegisterVariable (&sv_accelerate); sv_accelerate.inscribe();
Cvar_RegisterVariable (&sv_idealpitchscale); sv_idealpitchscale.inscribe();
Cvar_RegisterVariable (&sv_aim); sv_aim.inscribe();
Cvar_RegisterVariable (&sv_nostep); sv_nostep.inscribe();
Cvar_RegisterVariable (&sv_freezenonclients); sv_freezenonclients.inscribe();
Cvar_RegisterVariable (&sv_altnoclip); //johnfitz sv_altnoclip.inscribe(); //johnfitz
Cmd_AddCommand ("sv_protocol", &SV_Protocol_f); //johnfitz command::add ("sv_protocol", &SV_Protocol_f); //johnfitz
for (i=0 ; i<MAX_MODELS ; i++) for (i=0 ; i<MAX_MODELS ; i++)
sprintf (localmodels[i], "*%i", i); sprintf (localmodels[i], "*%i", i);
@@ -799,7 +799,7 @@ stats:
if (msg->cursize > 1024 && dev_peakstats.packetsize <= 1024) if (msg->cursize > 1024 && dev_peakstats.packetsize <= 1024)
Con_DWarning ("%i byte packet exceeds standard limit of 1024 (max = %d).\n", msg->cursize, msg->maxsize); Con_DWarning ("%i byte packet exceeds standard limit of 1024 (max = %d).\n", msg->cursize, msg->maxsize);
dev_stats.packetsize = msg->cursize; dev_stats.packetsize = msg->cursize;
dev_peakstats.packetsize = q_max(msg->cursize, dev_peakstats.packetsize); dev_peakstats.packetsize = std::max(msg->cursize, dev_peakstats.packetsize);
//johnfitz //johnfitz
} }
@@ -1415,7 +1415,7 @@ void SV_SendReconnect (void)
NET_SendToAll (&msg, 5.0); NET_SendToAll (&msg, 5.0);
if (!isDedicated) if (!isDedicated)
Cmd_ExecuteString ("reconnect\n", src_command); command::execute_string ("reconnect\n", command::source::command);
} }
@@ -1463,7 +1463,7 @@ void SV_SpawnServer (const char *server)
// let's not have any servers with no name // let's not have any servers with no name
if (hostname.string[0] == 0) if (hostname.string[0] == 0)
Cvar_Set ("hostname", "UNNAMED"); convar::set ("hostname", "UNNAMED");
scr_centertime_off = 0; scr_centertime_off = 0;
Con_DPrintf ("SpawnServer: %s\n",server); Con_DPrintf ("SpawnServer: %s\n",server);
@@ -1481,14 +1481,14 @@ void SV_SpawnServer (const char *server)
// make cvars consistant // make cvars consistant
// //
if (coop.value) if (coop.value)
Cvar_Set ("deathmatch", "0"); convar::set ("deathmatch", "0");
current_skill = (int)(skill.value + 0.5); current_skill = (int)(skill.value + 0.5);
if (current_skill < 0) if (current_skill < 0)
current_skill = 0; current_skill = 0;
if (current_skill > 3) if (current_skill > 3)
current_skill = 3; current_skill = 3;
Cvar_SetValue ("skill", (float)current_skill); convar::set_value ("skill", (float)current_skill);
// //
// set up the new server // set up the new server
+6 -6
View File
@@ -41,12 +41,12 @@ solid_edge items only clip against bsp models.
*/ */
cvar_t sv_friction = {"sv_friction","4",CVAR_NOTIFY|CVAR_SERVERINFO}; convar sv_friction{"sv_friction","4", {.notify = true,. server_info = true}};
cvar_t sv_stopspeed = {"sv_stopspeed","100",CVAR_NONE}; convar sv_stopspeed{"sv_stopspeed","100"};
cvar_t sv_gravity = {"sv_gravity","800",CVAR_NOTIFY|CVAR_SERVERINFO}; convar sv_gravity{"sv_gravity","800",{.notify = true,. server_info = true}};
cvar_t sv_maxvelocity = {"sv_maxvelocity","2000",CVAR_NONE}; convar sv_maxvelocity{"sv_maxvelocity","2000"};
cvar_t sv_nostep = {"sv_nostep","0",CVAR_NONE}; convar sv_nostep{"sv_nostep","0"};
cvar_t sv_freezenonclients = {"sv_freezenonclients","0",CVAR_NONE}; convar sv_freezenonclients{"sv_freezenonclients","0"};
#define MOVE_EPSILON 0.01 #define MOVE_EPSILON 0.01
+8 -8
View File
@@ -25,9 +25,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
edict_t *sv_player; edict_t *sv_player;
extern cvar_t sv_friction; extern convar sv_friction;
cvar_t sv_edgefriction = {"edgefriction", "2", CVAR_NONE}; convar sv_edgefriction{"edgefriction", "2"};
extern cvar_t sv_stopspeed; extern convar sv_stopspeed;
static vec3_t forward, right, up; static vec3_t forward, right, up;
@@ -40,8 +40,8 @@ qboolean onground;
usercmd_t cmd; usercmd_t cmd;
cvar_t sv_idealpitchscale = {"sv_idealpitchscale","0.8",CVAR_NONE}; convar sv_idealpitchscale{"sv_idealpitchscale","0.8"};
cvar_t sv_altnoclip = {"sv_altnoclip","1",CVAR_ARCHIVE}; //johnfitz convar sv_altnoclip{"sv_altnoclip","1",{.archive = true}}; //johnfitz
/* /*
=============== ===============
@@ -163,8 +163,8 @@ void SV_UserFriction (void)
SV_Accelerate SV_Accelerate
============== ==============
*/ */
cvar_t sv_maxspeed = {"sv_maxspeed", "320", CVAR_NOTIFY|CVAR_SERVERINFO}; convar sv_maxspeed{"sv_maxspeed", "320", {.notify = true,. server_info = true}};
cvar_t sv_accelerate = {"sv_accelerate", "10", CVAR_NONE}; convar sv_accelerate{"sv_accelerate", "10"};
void SV_Accelerate (float wishspeed, const vec3_t wishdir) void SV_Accelerate (float wishspeed, const vec3_t wishdir)
{ {
int i; int i;
@@ -570,7 +570,7 @@ nextmsg:
ret = 1; ret = 1;
if (ret == 1) if (ret == 1)
Cmd_ExecuteString (s, src_client); command::execute_string (s, command::source::client);
else else
Con_DPrintf("%s tried to %s\n", host_client->name, s); Con_DPrintf("%s tried to %s\n", host_client->name, s);
break; break;
+1 -1
View File
@@ -49,7 +49,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
qboolean isDedicated; qboolean isDedicated;
cvar_t sys_throttle = {"sys_throttle", "0.02", CVAR_ARCHIVE}; convar sys_throttle = {"sys_throttle", "0.02", {.archive = true}};
#define MAX_HANDLES 32 /* johnfitz -- was 10 */ #define MAX_HANDLES 32 /* johnfitz -- was 10 */
static FILE *sys_handles[MAX_HANDLES]; static FILE *sys_handles[MAX_HANDLES];
+124 -188
View File
@@ -32,42 +32,43 @@ when crossing a water boudnary.
*/ */
cvar_t scr_ofsx = {"scr_ofsx","0", CVAR_NONE}; convar scr_ofsx{"scr_ofsx", "0"};
cvar_t scr_ofsy = {"scr_ofsy","0", CVAR_NONE}; convar scr_ofsy{"scr_ofsy", "0"};
cvar_t scr_ofsz = {"scr_ofsz","0", CVAR_NONE}; convar scr_ofsz{"scr_ofsz", "0"};
cvar_t cl_rollspeed = {"cl_rollspeed", "200", CVAR_NONE}; convar cl_rollspeed{"cl_rollspeed", "200"};
cvar_t cl_rollangle = {"cl_rollangle", "2.0", CVAR_NONE}; convar cl_rollangle{"cl_rollangle", "2.0"};
cvar_t cl_bob = {"cl_bob","0.02", CVAR_NONE}; convar cl_bob{"cl_bob", "0.02"};
cvar_t cl_bobcycle = {"cl_bobcycle","0.6", CVAR_NONE}; convar cl_bobcycle{"cl_bobcycle", "0.6"};
cvar_t cl_bobup = {"cl_bobup","0.5", CVAR_NONE}; convar cl_bobup{"cl_bobup", "0.5"};
cvar_t v_kicktime = {"v_kicktime", "0.5", CVAR_NONE}; convar v_kicktime{"v_kicktime", "0.5"};
cvar_t v_kickroll = {"v_kickroll", "0.6", CVAR_NONE}; convar v_kickroll{"v_kickroll", "0.6"};
cvar_t v_kickpitch = {"v_kickpitch", "0.6", CVAR_NONE}; convar v_kickpitch{"v_kickpitch", "0.6"};
cvar_t v_gunkick = {"v_gunkick", "1", CVAR_NONE}; //johnfitz convar v_gunkick{"v_gunkick", "1"}; //johnfitz
cvar_t v_iyaw_cycle = {"v_iyaw_cycle", "2", CVAR_NONE}; convar v_iyaw_cycle{"v_iyaw_cycle", "2"};
cvar_t v_iroll_cycle = {"v_iroll_cycle", "0.5", CVAR_NONE}; convar v_iroll_cycle{"v_iroll_cycle", "0.5"};
cvar_t v_ipitch_cycle = {"v_ipitch_cycle", "1", CVAR_NONE}; convar v_ipitch_cycle{"v_ipitch_cycle", "1"};
cvar_t v_iyaw_level = {"v_iyaw_level", "0.3", CVAR_NONE}; convar v_iyaw_level{"v_iyaw_level", "0.3"};
cvar_t v_iroll_level = {"v_iroll_level", "0.1", CVAR_NONE}; convar v_iroll_level{"v_iroll_level", "0.1"};
cvar_t v_ipitch_level = {"v_ipitch_level", "0.3", CVAR_NONE}; convar v_ipitch_level{"v_ipitch_level", "0.3"};
cvar_t v_idlescale = {"v_idlescale", "0", CVAR_NONE}; convar v_idlescale{"v_idlescale", "0"};
cvar_t crosshair = {"crosshair", "0", CVAR_ARCHIVE}; convar crosshair = {"crosshair", "0", {.archive = true}};
cvar_t gl_cshiftpercent = {"gl_cshiftpercent", "100", CVAR_NONE}; convar gl_cshiftpercent{"gl_cshiftpercent", "100"};
cvar_t gl_cshiftpercent_contents = {"gl_cshiftpercent_contents", "100", CVAR_NONE}; // QuakeSpasm convar gl_cshiftpercent_contents{"gl_cshiftpercent_contents", "100"}; // QuakeSpasm
cvar_t gl_cshiftpercent_damage = {"gl_cshiftpercent_damage", "100", CVAR_NONE}; // QuakeSpasm convar gl_cshiftpercent_damage{"gl_cshiftpercent_damage", "100"}; // QuakeSpasm
cvar_t gl_cshiftpercent_bonus = {"gl_cshiftpercent_bonus", "100", CVAR_NONE}; // QuakeSpasm convar gl_cshiftpercent_bonus{"gl_cshiftpercent_bonus", "100"}; // QuakeSpasm
cvar_t gl_cshiftpercent_powerup = {"gl_cshiftpercent_powerup", "100", CVAR_NONE}; // QuakeSpasm convar gl_cshiftpercent_powerup{"gl_cshiftpercent_powerup", "100"}; // QuakeSpasm
cvar_t r_viewmodel_quake = {"r_viewmodel_quake", "0", CVAR_ARCHIVE}; convar r_viewmodel_quake{"r_viewmodel_quake", "0", {.archive = true}};
vec3_t v_punchangles[2]; //johnfitz -- copied from cl.punchangle. 0 is current, 1 is previous value. never the same unless map just loaded vec3_t v_punchangles[2];
//johnfitz -- copied from cl.punchangle. 0 is current, 1 is previous value. never the same unless map just loaded
/* /*
=============== ===============
@@ -76,8 +77,7 @@ V_CalcRoll
Used by view and sv_user Used by view and sv_user
=============== ===============
*/ */
float V_CalcRoll (vec3_t angles, vec3_t velocity) float V_CalcRoll(vec3_t angles, vec3_t velocity) {
{
vec3_t forward, right, up; vec3_t forward, right, up;
float sign; float sign;
float side; float side;
@@ -107,8 +107,7 @@ V_CalcBob
=============== ===============
*/ */
float V_CalcBob (void) float V_CalcBob(void) {
{
float bob; float bob;
float cycle; float cycle;
@@ -139,28 +138,24 @@ float V_CalcBob (void)
//============================================================================= //=============================================================================
cvar_t v_centermove = {"v_centermove", "0.15", CVAR_NONE}; convar v_centermove{"v_centermove", "0.15"};
cvar_t v_centerspeed = {"v_centerspeed","500", CVAR_NONE}; convar v_centerspeed{"v_centerspeed", "500"};
void V_StartPitchDrift (void) void V_StartPitchDrift(void) {
{
#if 1 #if 1
if (cl.laststop == cl.time) if (cl.laststop == cl.time) {
{
return; // something else is keeping it from drifting return; // something else is keeping it from drifting
} }
#endif #endif
if (cl.nodrift || !cl.pitchvel) if (cl.nodrift || !cl.pitchvel) {
{
cl.pitchvel = v_centerspeed.value; cl.pitchvel = v_centerspeed.value;
cl.nodrift = false; cl.nodrift = false;
cl.driftmove = 0; cl.driftmove = 0;
} }
} }
void V_StopPitchDrift (void) void V_StopPitchDrift(void) {
{
cl.laststop = cl.time; cl.laststop = cl.time;
cl.nodrift = true; cl.nodrift = true;
cl.pitchvel = 0; cl.pitchvel = 0;
@@ -179,8 +174,7 @@ Drifting is enabled when the center view key is hit, mlook is released and
lookspring is non 0, or when lookspring is non 0, or when
=============== ===============
*/ */
void V_DriftPitch (void) void V_DriftPitch(void) {
{
float delta, move; float delta, move;
if (noclip_anglehack || !cl.onground || cls.demoplayback) if (noclip_anglehack || !cl.onground || cls.demoplayback)
@@ -192,15 +186,13 @@ void V_DriftPitch (void)
} }
// don't count small mouse motion // don't count small mouse motion
if (cl.nodrift) if (cl.nodrift) {
{
if (fabs(cl.cmd.forwardmove) < cl_forwardspeed.value) if (fabs(cl.cmd.forwardmove) < cl_forwardspeed.value)
cl.driftmove = 0; cl.driftmove = 0;
else else
cl.driftmove += host_frametime; cl.driftmove += host_frametime;
if ( cl.driftmove > v_centermove.value) if (cl.driftmove > v_centermove.value) {
{
if (lookspring.value) if (lookspring.value)
V_StartPitchDrift(); V_StartPitchDrift();
} }
@@ -209,8 +201,7 @@ void V_DriftPitch (void)
delta = cl.idealpitch - cl.viewangles[PITCH]; delta = cl.idealpitch - cl.viewangles[PITCH];
if (!delta) if (!delta) {
{
cl.pitchvel = 0; cl.pitchvel = 0;
return; return;
} }
@@ -220,19 +211,14 @@ void V_DriftPitch (void)
//Con_Printf ("move: %f (%f)\n", move, host_frametime); //Con_Printf ("move: %f (%f)\n", move, host_frametime);
if (delta > 0) if (delta > 0) {
{ if (move > delta) {
if (move > delta)
{
cl.pitchvel = 0; cl.pitchvel = 0;
move = delta; move = delta;
} }
cl.viewangles[PITCH] += move; cl.viewangles[PITCH] += move;
} } else if (delta < 0) {
else if (delta < 0) if (move > -delta) {
{
if (move > -delta)
{
cl.pitchvel = 0; cl.pitchvel = 0;
move = -delta; move = -delta;
} }
@@ -264,8 +250,7 @@ float v_blend[4]; // rgba 0.0 - 1.0
V_ParseDamage V_ParseDamage
=============== ===============
*/ */
void V_ParseDamage (void) void V_ParseDamage(void) {
{
int armor, blood; int armor, blood;
vec3_t from; vec3_t from;
int i; int i;
@@ -291,20 +276,15 @@ void V_ParseDamage (void)
if (cl.cshifts[CSHIFT_DAMAGE].percent > 150) if (cl.cshifts[CSHIFT_DAMAGE].percent > 150)
cl.cshifts[CSHIFT_DAMAGE].percent = 150; cl.cshifts[CSHIFT_DAMAGE].percent = 150;
if (armor > blood) if (armor > blood) {
{
cl.cshifts[CSHIFT_DAMAGE].destcolor[0] = 200; cl.cshifts[CSHIFT_DAMAGE].destcolor[0] = 200;
cl.cshifts[CSHIFT_DAMAGE].destcolor[1] = 100; cl.cshifts[CSHIFT_DAMAGE].destcolor[1] = 100;
cl.cshifts[CSHIFT_DAMAGE].destcolor[2] = 100; cl.cshifts[CSHIFT_DAMAGE].destcolor[2] = 100;
} } else if (armor) {
else if (armor)
{
cl.cshifts[CSHIFT_DAMAGE].destcolor[0] = 220; cl.cshifts[CSHIFT_DAMAGE].destcolor[0] = 220;
cl.cshifts[CSHIFT_DAMAGE].destcolor[1] = 50; cl.cshifts[CSHIFT_DAMAGE].destcolor[1] = 50;
cl.cshifts[CSHIFT_DAMAGE].destcolor[2] = 50; cl.cshifts[CSHIFT_DAMAGE].destcolor[2] = 50;
} } else {
else
{
cl.cshifts[CSHIFT_DAMAGE].destcolor[0] = 255; cl.cshifts[CSHIFT_DAMAGE].destcolor[0] = 255;
cl.cshifts[CSHIFT_DAMAGE].destcolor[1] = 0; cl.cshifts[CSHIFT_DAMAGE].destcolor[1] = 0;
cl.cshifts[CSHIFT_DAMAGE].destcolor[2] = 0; cl.cshifts[CSHIFT_DAMAGE].destcolor[2] = 0;
@@ -335,12 +315,11 @@ void V_ParseDamage (void)
V_cshift_f V_cshift_f
================== ==================
*/ */
void V_cshift_f (void) void V_cshift_f(void) {
{ cshift_empty.destcolor[0] = atoi(command::argv(1).value_or("").c_str());
cshift_empty.destcolor[0] = atoi(Cmd_Argv(1)); cshift_empty.destcolor[1] = atoi(command::argv(2).value_or("").c_str());
cshift_empty.destcolor[1] = atoi(Cmd_Argv(2)); cshift_empty.destcolor[2] = atoi(command::argv(3).value_or("").c_str());
cshift_empty.destcolor[2] = atoi(Cmd_Argv(3)); cshift_empty.percent = atoi(command::argv(4).value_or("").c_str());
cshift_empty.percent = atoi(Cmd_Argv(4));
} }
@@ -351,8 +330,7 @@ V_BonusFlash_f
When you run over an item, the server sends this command When you run over an item, the server sends this command
================== ==================
*/ */
void V_BonusFlash_f (void) void V_BonusFlash_f(void) {
{
cl.cshifts[CSHIFT_BONUS].destcolor[0] = 215; cl.cshifts[CSHIFT_BONUS].destcolor[0] = 215;
cl.cshifts[CSHIFT_BONUS].destcolor[1] = 186; cl.cshifts[CSHIFT_BONUS].destcolor[1] = 186;
cl.cshifts[CSHIFT_BONUS].destcolor[2] = 69; cl.cshifts[CSHIFT_BONUS].destcolor[2] = 69;
@@ -366,10 +344,8 @@ V_SetContentsColor
Underwater, lava, etc each has a color shift Underwater, lava, etc each has a color shift
============= =============
*/ */
void V_SetContentsColor (int contents) void V_SetContentsColor(int contents) {
{ switch (contents) {
switch (contents)
{
case CONTENTS_EMPTY: case CONTENTS_EMPTY:
case CONTENTS_SOLID: case CONTENTS_SOLID:
case CONTENTS_SKY: //johnfitz -- no blend in sky case CONTENTS_SKY: //johnfitz -- no blend in sky
@@ -391,37 +367,28 @@ void V_SetContentsColor (int contents)
V_CalcPowerupCshift V_CalcPowerupCshift
============= =============
*/ */
void V_CalcPowerupCshift (void) void V_CalcPowerupCshift(void) {
{ if (cl.items & IT_QUAD) {
if (cl.items & IT_QUAD)
{
cl.cshifts[CSHIFT_POWERUP].destcolor[0] = 0; cl.cshifts[CSHIFT_POWERUP].destcolor[0] = 0;
cl.cshifts[CSHIFT_POWERUP].destcolor[1] = 0; cl.cshifts[CSHIFT_POWERUP].destcolor[1] = 0;
cl.cshifts[CSHIFT_POWERUP].destcolor[2] = 255; cl.cshifts[CSHIFT_POWERUP].destcolor[2] = 255;
cl.cshifts[CSHIFT_POWERUP].percent = 30; cl.cshifts[CSHIFT_POWERUP].percent = 30;
} } else if (cl.items & IT_SUIT) {
else if (cl.items & IT_SUIT)
{
cl.cshifts[CSHIFT_POWERUP].destcolor[0] = 0; cl.cshifts[CSHIFT_POWERUP].destcolor[0] = 0;
cl.cshifts[CSHIFT_POWERUP].destcolor[1] = 255; cl.cshifts[CSHIFT_POWERUP].destcolor[1] = 255;
cl.cshifts[CSHIFT_POWERUP].destcolor[2] = 0; cl.cshifts[CSHIFT_POWERUP].destcolor[2] = 0;
cl.cshifts[CSHIFT_POWERUP].percent = 20; cl.cshifts[CSHIFT_POWERUP].percent = 20;
} } else if (cl.items & IT_INVISIBILITY) {
else if (cl.items & IT_INVISIBILITY)
{
cl.cshifts[CSHIFT_POWERUP].destcolor[0] = 100; cl.cshifts[CSHIFT_POWERUP].destcolor[0] = 100;
cl.cshifts[CSHIFT_POWERUP].destcolor[1] = 100; cl.cshifts[CSHIFT_POWERUP].destcolor[1] = 100;
cl.cshifts[CSHIFT_POWERUP].destcolor[2] = 100; cl.cshifts[CSHIFT_POWERUP].destcolor[2] = 100;
cl.cshifts[CSHIFT_POWERUP].percent = 100; cl.cshifts[CSHIFT_POWERUP].percent = 100;
} } else if (cl.items & IT_INVULNERABILITY) {
else if (cl.items & IT_INVULNERABILITY)
{
cl.cshifts[CSHIFT_POWERUP].destcolor[0] = 255; cl.cshifts[CSHIFT_POWERUP].destcolor[0] = 255;
cl.cshifts[CSHIFT_POWERUP].destcolor[1] = 255; cl.cshifts[CSHIFT_POWERUP].destcolor[1] = 255;
cl.cshifts[CSHIFT_POWERUP].destcolor[2] = 0; cl.cshifts[CSHIFT_POWERUP].destcolor[2] = 0;
cl.cshifts[CSHIFT_POWERUP].percent = 30; cl.cshifts[CSHIFT_POWERUP].percent = 30;
} } else
else
cl.cshifts[CSHIFT_POWERUP].percent = 0; cl.cshifts[CSHIFT_POWERUP].percent = 0;
} }
@@ -430,11 +397,10 @@ void V_CalcPowerupCshift (void)
V_CalcBlend V_CalcBlend
============= =============
*/ */
void V_CalcBlend (void) void V_CalcBlend(void) {
{
float r, g, b, a, a2; float r, g, b, a, a2;
int j; int j;
cvar_t *cshiftpercent_cvars[NUM_CSHIFTS] = { convar *cshiftpercent_cvars[NUM_CSHIFTS] = {
&gl_cshiftpercent_contents, &gl_cshiftpercent_contents,
&gl_cshiftpercent_damage, &gl_cshiftpercent_damage,
&gl_cshiftpercent_bonus, &gl_cshiftpercent_bonus,
@@ -446,8 +412,7 @@ void V_CalcBlend (void)
b = 0; b = 0;
a = 0; a = 0;
for (j=0 ; j<NUM_CSHIFTS ; j++) for (j = 0; j < NUM_CSHIFTS; j++) {
{
if (!gl_cshiftpercent.value) if (!gl_cshiftpercent.value)
continue; continue;
@@ -484,8 +449,7 @@ void V_CalcBlend (void)
V_UpdateBlend -- johnfitz -- V_UpdatePalette cleaned up and renamed V_UpdateBlend -- johnfitz -- V_UpdatePalette cleaned up and renamed
============= =============
*/ */
void V_UpdateBlend (void) void V_UpdateBlend(void) {
{
int i, j; int i, j;
qboolean blend_changed; qboolean blend_changed;
@@ -493,16 +457,13 @@ void V_UpdateBlend (void)
blend_changed = false; blend_changed = false;
for (i=0 ; i<NUM_CSHIFTS ; i++) for (i = 0; i < NUM_CSHIFTS; i++) {
{ if (cl.cshifts[i].percent != cl.prev_cshifts[i].percent) {
if (cl.cshifts[i].percent != cl.prev_cshifts[i].percent)
{
blend_changed = true; blend_changed = true;
cl.prev_cshifts[i].percent = cl.cshifts[i].percent; cl.prev_cshifts[i].percent = cl.cshifts[i].percent;
} }
for (j = 0; j < 3; j++) for (j = 0; j < 3; j++)
if (cl.cshifts[i].destcolor[j] != cl.prev_cshifts[i].destcolor[j]) if (cl.cshifts[i].destcolor[j] != cl.prev_cshifts[i].destcolor[j]) {
{
blend_changed = true; blend_changed = true;
cl.prev_cshifts[i].destcolor[j] = cl.cshifts[i].destcolor[j]; cl.prev_cshifts[i].destcolor[j] = cl.cshifts[i].destcolor[j];
} }
@@ -527,8 +488,7 @@ void V_UpdateBlend (void)
V_PolyBlend -- johnfitz -- moved here from gl_rmain.c, and rewritten to use glOrtho V_PolyBlend -- johnfitz -- moved here from gl_rmain.c, and rewritten to use glOrtho
============ ============
*/ */
void V_PolyBlend (void) void V_PolyBlend(void) {
{
if (!gl_polyblend.value || !v_blend[3]) if (!gl_polyblend.value || !v_blend[3])
return; return;
@@ -569,8 +529,7 @@ void V_PolyBlend (void)
============================================================================== ==============================================================================
*/ */
float angledelta (float a) float angledelta(float a) {
{
a = anglemod(a); a = anglemod(a);
if (a > 180) if (a > 180)
a -= 360; a -= 360;
@@ -582,8 +541,7 @@ float angledelta (float a)
CalcGunAngle CalcGunAngle
================== ==================
*/ */
void CalcGunAngle (void) void CalcGunAngle(void) {
{
float yaw, pitch, move; float yaw, pitch, move;
static float oldyaw = 0; static float oldyaw = 0;
static float oldpitch = 0; static float oldpitch = 0;
@@ -602,24 +560,18 @@ void CalcGunAngle (void)
if (pitch < -10) if (pitch < -10)
pitch = -10; pitch = -10;
move = host_frametime * 20; move = host_frametime * 20;
if (yaw > oldyaw) if (yaw > oldyaw) {
{
if (oldyaw + move < yaw) if (oldyaw + move < yaw)
yaw = oldyaw + move; yaw = oldyaw + move;
} } else {
else
{
if (oldyaw - move > yaw) if (oldyaw - move > yaw)
yaw = oldyaw - move; yaw = oldyaw - move;
} }
if (pitch > oldpitch) if (pitch > oldpitch) {
{
if (oldpitch + move < pitch) if (oldpitch + move < pitch)
pitch = oldpitch + move; pitch = oldpitch + move;
} } else {
else
{
if (oldpitch - move > pitch) if (oldpitch - move > pitch)
pitch = oldpitch - move; pitch = oldpitch - move;
} }
@@ -640,8 +592,7 @@ void CalcGunAngle (void)
V_BoundOffsets V_BoundOffsets
============== ==============
*/ */
void V_BoundOffsets (void) void V_BoundOffsets(void) {
{
entity_t *ent; entity_t *ent;
ent = &cl_entities[cl.viewentity]; ent = &cl_entities[cl.viewentity];
@@ -670,8 +621,7 @@ V_AddIdle
Idle swaying Idle swaying
============== ==============
*/ */
void V_AddIdle (void) void V_AddIdle(void) {
{
r_refdef.viewangles[ROLL] += v_idlescale.value * sin(cl.time * v_iroll_cycle.value) * v_iroll_level.value; r_refdef.viewangles[ROLL] += v_idlescale.value * sin(cl.time * v_iroll_cycle.value) * v_iroll_level.value;
r_refdef.viewangles[PITCH] += v_idlescale.value * sin(cl.time * v_ipitch_cycle.value) * v_ipitch_level.value; r_refdef.viewangles[PITCH] += v_idlescale.value * sin(cl.time * v_ipitch_cycle.value) * v_ipitch_level.value;
r_refdef.viewangles[YAW] += v_idlescale.value * sin(cl.time * v_iyaw_cycle.value) * v_iyaw_level.value; r_refdef.viewangles[YAW] += v_idlescale.value * sin(cl.time * v_iyaw_cycle.value) * v_iyaw_level.value;
@@ -685,22 +635,19 @@ V_CalcViewRoll
Roll is induced by movement and damage Roll is induced by movement and damage
============== ==============
*/ */
void V_CalcViewRoll (void) void V_CalcViewRoll(void) {
{
float side; float side;
side = V_CalcRoll(cl_entities[cl.viewentity].angles, cl.velocity); side = V_CalcRoll(cl_entities[cl.viewentity].angles, cl.velocity);
r_refdef.viewangles[ROLL] += side; r_refdef.viewangles[ROLL] += side;
if (v_dmg_time > 0) if (v_dmg_time > 0) {
{
r_refdef.viewangles[ROLL] += v_dmg_time / v_kicktime.value * v_dmg_roll; r_refdef.viewangles[ROLL] += v_dmg_time / v_kicktime.value * v_dmg_roll;
r_refdef.viewangles[PITCH] += v_dmg_time / v_kicktime.value * v_dmg_pitch; r_refdef.viewangles[PITCH] += v_dmg_time / v_kicktime.value * v_dmg_pitch;
v_dmg_time -= host_frametime; v_dmg_time -= host_frametime;
} }
if (cl.stats[STAT_HEALTH] <= 0) if (cl.stats[STAT_HEALTH] <= 0) {
{
r_refdef.viewangles[ROLL] = 80; // dead view angle r_refdef.viewangles[ROLL] = 80; // dead view angle
return; return;
} }
@@ -712,8 +659,7 @@ V_CalcIntermissionRefdef
================== ==================
*/ */
void V_CalcIntermissionRefdef (void) void V_CalcIntermissionRefdef(void) {
{
entity_t *ent, *view; entity_t *ent, *view;
float old; float old;
@@ -738,8 +684,7 @@ void V_CalcIntermissionRefdef (void)
V_CalcRefdef V_CalcRefdef
================== ==================
*/ */
void V_CalcRefdef (void) void V_CalcRefdef(void) {
{
entity_t *ent, *view; entity_t *ent, *view;
int i; int i;
vec3_t forward, right, up; vec3_t forward, right, up;
@@ -806,8 +751,7 @@ void V_CalcRefdef (void)
//johnfitz -- removed all gun position fudging code (was used to keep gun from getting covered by sbar) //johnfitz -- removed all gun position fudging code (was used to keep gun from getting covered by sbar)
//MarkV -- restored this with r_viewmodel_quake cvar //MarkV -- restored this with r_viewmodel_quake cvar
if (r_viewmodel_quake.value) if (r_viewmodel_quake.value) {
{
if (scr_viewsize.value == 110) if (scr_viewsize.value == 110)
view->origin[2] += 1; view->origin[2] += 1;
else if (scr_viewsize.value == 100) else if (scr_viewsize.value == 100)
@@ -818,12 +762,10 @@ void V_CalcRefdef (void)
view->origin[2] += 0.5; view->origin[2] += 0.5;
} }
if (ent->lerpflags & LERP_FINISH) if (ent->lerpflags & LERP_FINISH) {
{
view->lerpflags |= LERP_FINISH; view->lerpflags |= LERP_FINISH;
view->lerpfinish = ent->lerpfinish; view->lerpfinish = ent->lerpfinish;
} } else
else
view->lerpflags &= ~LERP_FINISH; view->lerpflags &= ~LERP_FINISH;
view->model = cl.model_precache[cl.stats[STAT_WEAPON]]; view->model = cl.model_precache[cl.stats[STAT_WEAPON]];
@@ -837,15 +779,14 @@ void V_CalcRefdef (void)
if (v_gunkick.value == 2) //lerped kick if (v_gunkick.value == 2) //lerped kick
{ {
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
if (punch[i] != v_punchangles[0][i]) if (punch[i] != v_punchangles[0][i]) {
{
//speed determined by how far we need to lerp in 1/10th of a second //speed determined by how far we need to lerp in 1/10th of a second
delta = (v_punchangles[0][i] - v_punchangles[1][i]) * host_frametime * 10; delta = (v_punchangles[0][i] - v_punchangles[1][i]) * host_frametime * 10;
if (delta > 0) if (delta > 0)
punch[i] = q_min(punch[i]+delta, v_punchangles[0][i]); punch[i] = std::min(punch[i]+delta, v_punchangles[0][i]);
else if (delta < 0) else if (delta < 0)
punch[i] = q_max(punch[i]+delta, v_punchangles[0][i]); punch[i] = std::max(punch[i]+delta, v_punchangles[0][i]);
} }
VectorAdd(r_refdef.viewangles, punch, r_refdef.viewangles); VectorAdd(r_refdef.viewangles, punch, r_refdef.viewangles);
@@ -870,8 +811,7 @@ void V_CalcRefdef (void)
oldz = ent->origin[2] - 12; oldz = ent->origin[2] - 12;
r_refdef.vieworg[2] += oldz - ent->origin[2]; r_refdef.vieworg[2] += oldz - ent->origin[2];
view->origin[2] += oldz - ent->origin[2]; view->origin[2] += oldz - ent->origin[2];
} } else
else
oldz = ent->origin[2]; oldz = ent->origin[2];
if (chase_active.value) if (chase_active.value)
@@ -886,8 +826,7 @@ Resets the viewentity angles to the last values received from the server
(undoing the manual adjustments performed by V_CalcRefdef) (undoing the manual adjustments performed by V_CalcRefdef)
================== ==================
*/ */
void V_RestoreAngles (void) void V_RestoreAngles(void) {
{
entity_t *ent = &cl_entities[cl.viewentity]; entity_t *ent = &cl_entities[cl.viewentity];
VectorCopy(ent->msg_angles[0], ent->angles); VectorCopy(ent->msg_angles[0], ent->angles);
} }
@@ -902,8 +841,7 @@ the entity origin, so any view position inside that will be valid
*/ */
extern vrect_t scr_vrect; extern vrect_t scr_vrect;
void V_RenderView (void) void V_RenderView(void) {
{
if (con_forcedup) if (con_forcedup)
return; return;
@@ -932,44 +870,42 @@ void V_RenderView (void)
V_Init V_Init
============= =============
*/ */
void V_Init (void) void V_Init(void) {
{ command::add("v_cshift", V_cshift_f);
Cmd_AddCommand ("v_cshift", V_cshift_f); command::add("bf", V_BonusFlash_f);
Cmd_AddCommand ("bf", V_BonusFlash_f); command::add("centerview", V_StartPitchDrift);
Cmd_AddCommand ("centerview", V_StartPitchDrift);
Cvar_RegisterVariable (&v_centermove); v_centermove.inscribe();
Cvar_RegisterVariable (&v_centerspeed); v_centerspeed.inscribe();
Cvar_RegisterVariable (&v_iyaw_cycle); v_iyaw_cycle.inscribe();
Cvar_RegisterVariable (&v_iroll_cycle); v_iroll_cycle.inscribe();
Cvar_RegisterVariable (&v_ipitch_cycle); v_ipitch_cycle.inscribe();
Cvar_RegisterVariable (&v_iyaw_level); v_iyaw_level.inscribe();
Cvar_RegisterVariable (&v_iroll_level); v_iroll_level.inscribe();
Cvar_RegisterVariable (&v_ipitch_level); v_ipitch_level.inscribe();
Cvar_RegisterVariable (&v_idlescale); v_idlescale.inscribe();
Cvar_RegisterVariable (&crosshair); crosshair.inscribe();
Cvar_RegisterVariable (&gl_cshiftpercent); gl_cshiftpercent.inscribe();
Cvar_RegisterVariable (&gl_cshiftpercent_contents); // QuakeSpasm gl_cshiftpercent_contents.inscribe(); // QuakeSpasm
Cvar_RegisterVariable (&gl_cshiftpercent_damage); // QuakeSpasm gl_cshiftpercent_damage.inscribe(); // QuakeSpasm
Cvar_RegisterVariable (&gl_cshiftpercent_bonus); // QuakeSpasm gl_cshiftpercent_bonus.inscribe(); // QuakeSpasm
Cvar_RegisterVariable (&gl_cshiftpercent_powerup); // QuakeSpasm gl_cshiftpercent_powerup.inscribe(); // QuakeSpasm
Cvar_RegisterVariable (&scr_ofsx); scr_ofsx.inscribe();
Cvar_RegisterVariable (&scr_ofsy); scr_ofsy.inscribe();
Cvar_RegisterVariable (&scr_ofsz); scr_ofsz.inscribe();
Cvar_RegisterVariable (&cl_rollspeed); cl_rollspeed.inscribe();
Cvar_RegisterVariable (&cl_rollangle); cl_rollangle.inscribe();
Cvar_RegisterVariable (&cl_bob); cl_bob.inscribe();
Cvar_RegisterVariable (&cl_bobcycle); cl_bobcycle.inscribe();
Cvar_RegisterVariable (&cl_bobup); cl_bobup.inscribe();
Cvar_RegisterVariable (&v_kicktime); v_kicktime.inscribe();
Cvar_RegisterVariable (&v_kickroll); v_kickroll.inscribe();
Cvar_RegisterVariable (&v_kickpitch); v_kickpitch.inscribe();
Cvar_RegisterVariable (&v_gunkick); //johnfitz v_gunkick.inscribe(); //johnfitz
Cvar_RegisterVariable (&r_viewmodel_quake); //MarkV r_viewmodel_quake.inscribe(); //MarkV
} }
+2 -2
View File
@@ -23,8 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef _QUAKE_VIEW_H #ifndef _QUAKE_VIEW_H
#define _QUAKE_VIEW_H #define _QUAKE_VIEW_H
extern cvar_t vid_gamma; extern convar vid_gamma;
extern cvar_t vid_contrast; extern convar vid_contrast;
extern float v_blend[4]; extern float v_blend[4];
+3 -3
View File
@@ -238,7 +238,7 @@ void *Z_Realloc(void *ptr, int size)
Sys_Error ("Z_Realloc: failed on allocation of %i bytes", size); Sys_Error ("Z_Realloc: failed on allocation of %i bytes", size);
if (ptr != old_ptr) if (ptr != old_ptr)
memmove (ptr, old_ptr, q_min(old_size, size)); memmove (ptr, old_ptr, std::min(old_size, size));
if (old_size < size) if (old_size < size)
memset ((byte *)ptr + old_size, 0, size - old_size); memset ((byte *)ptr + old_size, 0, size - old_size);
@@ -838,7 +838,7 @@ void Cache_Init (void)
cache_head.next = cache_head.prev = &cache_head; cache_head.next = cache_head.prev = &cache_head;
cache_head.lru_next = cache_head.lru_prev = &cache_head; cache_head.lru_next = cache_head.lru_prev = &cache_head;
Cmd_AddCommand ("flush", Cache_Flush); command::add ("flush", Cache_Flush);
} }
/* /*
@@ -984,6 +984,6 @@ void Memory_Init (void *buf, int size)
mainzone = (memzone_t *) Hunk_AllocName (zonesize, "zone" ); mainzone = (memzone_t *) Hunk_AllocName (zonesize, "zone" );
Memory_InitZone (mainzone, zonesize); Memory_InitZone (mainzone, zonesize);
Cmd_AddCommand ("hunk_print", Hunk_Print_f); //johnfitz command::add ("hunk_print", Hunk_Print_f); //johnfitz
} }