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);
+493 -672
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 */
+755 -979
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);
+90 -100
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;
@@ -103,7 +99,7 @@ void Fog_ParseServerMessage (void)
time = MSG_ReadShort() / 100.0; time = MSG_ReadShort() / 100.0;
if (time < 0.0f) time = 0.0f; if (time < 0.0f) time = 0.0f;
Fog_Update (density, red, green, blue, time); Fog_Update(density, red, green, blue, time);
} }
/* /*
@@ -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;
@@ -264,12 +262,12 @@ float *Fog_GetColor (void)
} }
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
c[i] = CLAMP (0.f, c[i], 1.f); c[i] = CLAMP(0.f, c[i], 1.f);
} }
//find closest 24-bit RGB value, so solid-colored sky can match the fog perfectly //find closest 24-bit RGB value, so solid-colored sky can match the fog perfectly
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
c[i] = (float)(Q_rint(c[i] * 255)) / 255.0f; c[i] = (float) (Q_rint(c[i] * 255)) / 255.0f;
} }
return c; return c;
@@ -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,9 +333,8 @@ 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)
glFogfv(GL_FOG_COLOR, color); glFogfv(GL_FOG_COLOR, color);
@@ -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,10 +379,9 @@ 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;
@@ -411,7 +402,7 @@ void Fog_Init (void)
fog_green = DEFAULT_GRAY; fog_green = DEFAULT_GRAY;
fog_blue = DEFAULT_GRAY; fog_blue = DEFAULT_GRAY;
Fog_SetupState (); Fog_SetupState();
} }
/* /*
@@ -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;
} }
+359 -420
View File
File diff suppressed because it is too large Load Diff
+235 -259
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,9 +60,8 @@ 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,9 +69,8 @@ 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,14 +78,13 @@ 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;
s = (int)r_clearcolor.value & 0xFF; s = (int) r_clearcolor.value & 0xFF;
rgb = (byte*)(d_8to24table + s); rgb = (byte *) (d_8to24table + s);
glClearColor (rgb[0]/255.0,rgb[1]/255.0,rgb[2]/255.0,0); glClearColor(rgb[0] / 255.0, rgb[1] / 255.0, rgb[2] / 255.0, 0);
} }
/* /*
@@ -93,11 +92,10 @@ 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,79 +156,78 @@ 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
Sky_Init (); //johnfitz Sky_Init(); //johnfitz
Fog_Init (); //johnfitz Fog_Init(); //johnfitz
} }
/* /*
@@ -243,18 +235,16 @@ 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,39 +255,40 @@ 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;
int skinnum; int skinnum;
//get correct texture pixels //get correct texture pixels
currententity = &cl_entities[1+playernum]; currententity = &cl_entities[1 + playernum];
if (!currententity->model || currententity->model->type != mod_alias) if (!currententity->model || currententity->model->type != mod_alias)
return; return;
paliashdr = (aliashdr_t *)Mod_Extradata (currententity->model); paliashdr = (aliashdr_t *) Mod_Extradata(currententity->model);
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;
} }
pixels = (byte *)paliashdr + paliashdr->texels[skinnum]; // This is not a persistent place! pixels = (byte *) paliashdr + paliashdr->texels[skinnum]; // This is not a persistent place!
//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,12 +296,11 @@ 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)
for (i=0; i<MAX_SCOREBOARD; i++) for (i = 0; i < MAX_SCOREBOARD; i++)
playertextures[i] = NULL; playertextures[i] = NULL;
} }
@@ -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,31 +374,30 @@ 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++)
d_lightstylevalue[i] = 264; // normal light value d_lightstylevalue[i] = 264; // normal light value
// clear out efrags in case the level hasn't been reloaded // clear out efrags in case the level hasn't been reloaded
// FIXME: is this one short? // FIXME: is this one short?
for (i=0 ; i<cl.worldmodel->numleafs ; i++) for (i = 0; i < cl.worldmodel->numleafs; i++)
cl.worldmodel->leafs[i].efrags = NULL; cl.worldmodel->leafs[i].efrags = NULL;
r_viewleaf = NULL; r_viewleaf = NULL;
R_ClearParticles (); R_ClearParticles();
GL_BuildLightmaps (); GL_BuildLightmaps();
GL_BuildBModelVertexBuffer (); GL_BuildBModelVertexBuffer();
//ericw -- no longer load alias models into a VBO here, it's done in Mod_LoadAliasModel //ericw -- no longer load alias models into a VBO here, it's done in Mod_LoadAliasModel
r_framecount = 0; //johnfitz -- paranoid? r_framecount = 0; //johnfitz -- paranoid?
r_visframecount = 0; //johnfitz -- paranoid? r_visframecount = 0; //johnfitz -- paranoid?
Sky_NewMap (); //johnfitz -- skybox in worldspawn Sky_NewMap(); //johnfitz -- skybox in worldspawn
Fog_NewMap (); //johnfitz -- global fog in worldspawn Fog_NewMap(); //johnfitz -- global fog in worldspawn
R_ParseWorldspawn (); //ericw -- wateralpha, lavaalpha, telealpha, slimealpha in worldspawn R_ParseWorldspawn(); //ericw -- wateralpha, lavaalpha, telealpha, slimealpha in worldspawn
load_subdivide_size = gl_subdivide_size.value; //johnfitz -- is this the right place to set this? load_subdivide_size = gl_subdivide_size.value; //johnfitz -- is this the right place to set this?
} }
@@ -411,71 +409,63 @@ 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();
GL_EndRendering (); GL_EndRendering();
} }
glFinish (); glFinish();
stop = Sys_DoubleTime (); stop = Sys_DoubleTime();
time = stop-start; time = stop - start;
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));
GL_GetShaderInfoLogFunc (shader, sizeof(infolog), NULL, infolog); GL_GetShaderInfoLogFunc(shader, sizeof(infolog), NULL, infolog);
Con_Warning ("GLSL program failed to compile: %s", infolog); Con_Warning("GLSL program failed to compile: %s", infolog);
return false; return false;
} }
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));
GL_GetProgramInfoLogFunc (program, sizeof(infolog), NULL, infolog); GL_GetProgramInfoLogFunc(program, sizeof(infolog), NULL, infolog);
Con_Warning ("GLSL program failed to link: %s", infolog); Con_Warning("GLSL program failed to link: %s", infolog);
return false; return false;
} }
@@ -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,55 +498,49 @@ 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;
if (!gl_glsl_able) if (!gl_glsl_able)
return 0; return 0;
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;
} }
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;
} }
program = GL_CreateProgramFunc (); program = GL_CreateProgramFunc();
GL_AttachShaderFunc (program, vertShader); GL_AttachShaderFunc(program, vertShader);
GL_DeleteShaderFunc (vertShader); GL_DeleteShaderFunc(vertShader);
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");
gl_programs[gl_num_programs] = program; gl_programs[gl_num_programs] = program;
gl_num_programs++; gl_num_programs++;
@@ -574,16 +556,14 @@ 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;
} }
gl_num_programs = 0; gl_num_programs = 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;
@@ -614,14 +592,13 @@ void GL_BindBuffer (GLenum target, GLuint buffer)
cache = &current_element_array_buffer; cache = &current_element_array_buffer;
break; break;
default: default:
Host_Error("GL_BindBuffer: unsupported target %d", (int)target); Host_Error("GL_BindBuffer: unsupported target %d", (int) target);
return; return;
} }
if (*cache != buffer) if (*cache != buffer) {
{
*cache = buffer; *cache = buffer;
GL_BindBufferFunc (target, *cache); GL_BindBufferFunc(target, *cache);
} }
} }
@@ -633,13 +610,12 @@ 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;
current_array_buffer = 0; current_array_buffer = 0;
current_element_array_buffer = 0; current_element_array_buffer = 0;
GL_BindBufferFunc (GL_ARRAY_BUFFER, 0); GL_BindBufferFunc(GL_ARRAY_BUFFER, 0);
GL_BindBufferFunc (GL_ELEMENT_ARRAY_BUFFER, 0); GL_BindBufferFunc(GL_ELEMENT_ARRAY_BUFFER, 0);
} }
+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;
+389 -467
View File
File diff suppressed because it is too large Load Diff
+514 -670
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);
} }
+175 -260
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;
@@ -220,25 +203,22 @@ void IN_Activate (void)
{ {
// Work around https://github.com/sezero/quakespasm/issues/48 // Work around https://github.com/sezero/quakespasm/issues/48
int width, height; int width, height;
SDL_GetWindowSize((SDL_Window*) VID_GetWindow(), &width, &height); SDL_GetWindowSize((SDL_Window *) VID_GetWindow(), &width, &height);
SDL_WarpMouseInWindow((SDL_Window*) VID_GetWindow(), width / 2, height / 2); SDL_WarpMouseInWindow((SDL_Window *) VID_GetWindow(), width / 2, height / 2);
} }
#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,68 +272,57 @@ 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;
} }
// Load additional SDL2 controller definitions from gamecontrollerdb.txt // Load additional SDL2 controller definitions from gamecontrollerdb.txt
q_snprintf (controllerdb, sizeof(controllerdb), "%s/gamecontrollerdb.txt", com_basedir); q_snprintf(controllerdb, sizeof(controllerdb), "%s/gamecontrollerdb.txt", com_basedir);
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);
// 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)
SDL_EnableUNICODE (textmode); SDL_EnableUNICODE(textmode);
if (SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL) == -1) if (SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL) == -1)
Con_Printf("Warning: SDL_EnableKeyRepeat() failed.\n"); Con_Printf("Warning: SDL_EnableKeyRepeat() failed.\n");
#else #else
@@ -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;
@@ -714,28 +666,24 @@ void IN_MouseMove(usercmd_t *cmd)
if (cl.paused || key_dest != key_game) if (cl.paused || key_dest != key_game)
return; return;
if ( (in_strafe.state & 1) || (lookstrafe.value && (in_mlook.state & 1) )) if ((in_strafe.state & 1) || (lookstrafe.value && (in_mlook.state & 1)))
cmd->sidemove += m_side.value * dmx; cmd->sidemove += m_side.value * dmx;
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;
@@ -828,7 +767,7 @@ static inline int IN_SDL_KeysymToQuakeKey(SDLKey sym)
case SDLK_NUMLOCK: return K_KP_NUMLOCK; case SDLK_NUMLOCK: return K_KP_NUMLOCK;
case SDLK_KP_DIVIDE: return K_KP_SLASH; case SDLK_KP_DIVIDE: return K_KP_SLASH;
case SDLK_KP_MULTIPLY: return K_KP_STAR; case SDLK_KP_MULTIPLY: return K_KP_STAR;
case SDLK_KP_MINUS:return K_KP_MINUS; case SDLK_KP_MINUS: return K_KP_MINUS;
case SDLK_KP7: return K_KP_HOME; case SDLK_KP7: return K_KP_HOME;
case SDLK_KP8: return K_KP_UPARROW; case SDLK_KP8: return K_KP_UPARROW;
case SDLK_KP9: return K_KP_PGUP; case SDLK_KP9: return K_KP_PGUP;
@@ -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,64 +917,52 @@ 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",
eventtype, eventtype,
SDL_GetScancodeName(event->key.keysym.scancode), SDL_GetScancodeName(event->key.keysym.scancode),
SDL_GetKeyName(event->key.keysym.sym), SDL_GetKeyName(event->key.keysym.sym),
Sys_DoubleTime()); Sys_DoubleTime());
#else #else
Con_Printf ("%s sym: '%s' unicode: %04x time: %g\n", Con_Printf("%s sym: '%s' unicode: %04x time: %g\n",
eventtype, eventtype,
SDL_GetKeyName(event->key.keysym.sym), SDL_GetKeyName(event->key.keysym.sym),
(int)event->key.keysym.unicode, (int) event->key.keysym.unicode,
Sys_DoubleTime()); Sys_DoubleTime());
#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();
} }
@@ -1054,9 +979,9 @@ void IN_SendKeyEvents (void)
// (shift for uppercase, etc.) for us. // (shift for uppercase, etc.) for us.
{ {
unsigned char *ch; unsigned char *ch;
for (ch = (unsigned char *)event.text.text; *ch; ch++) for (ch = (unsigned char *) event.text.text; *ch; ch++)
if ((*ch & ~0x7F) == 0) if ((*ch & ~0x7F) == 0)
Char_Event (*ch); Char_Event(*ch);
} }
break; break;
#endif #endif
@@ -1076,20 +1001,19 @@ void IN_SendKeyEvents (void)
#endif #endif
// also pass along the underlying keycode using the proper current layout for Y/N prompts. // also pass along the underlying keycode using the proper current layout for Y/N prompts.
Key_EventWithKeycode (key, down, event.key.keysym.sym); Key_EventWithKeycode(key, down, event.key.keysym.sym);
#if !defined(USE_SDL2) #if !defined(USE_SDL2)
if (down && (event.key.keysym.unicode & ~0x7F) == 0) if (down && (event.key.keysym.unicode & ~0x7F) == 0)
Char_Event (event.key.keysym.unicode); Char_Event(event.key.keysym.unicode);
#endif #endif
break; break;
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:
@@ -1148,8 +1064,8 @@ void IN_SendKeyEvents (void)
#endif #endif
case SDL_QUIT: case SDL_QUIT:
CL_Disconnect (); CL_Disconnect();
Sys_Quit (); Sys_Quit();
break; break;
default: default:
@@ -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 {
+777 -905
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;
+243 -376
View File
File diff suppressed because it is too large Load Diff
+148 -243
View File
@@ -46,8 +46,10 @@ qboolean slistLocal = true;
static double slistStartTime; 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)
@@ -106,7 +106,7 @@ qsocket_t *NET_NewQSocket (void)
sock->disconnected = false; sock->disconnected = false;
sock->connecttime = net_time; sock->connecttime = net_time;
Q_strcpy (sock->address,"UNSET ADDRESS"); Q_strcpy(sock->address, "UNSET ADDRESS");
sock->driver = net_driverlevel; sock->driver = net_driverlevel;
sock->socket = 0; sock->socket = 0;
sock->driverdata = NULL; sock->driverdata = NULL;
@@ -125,26 +125,22 @@ 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;
} }
} }
if (!s) if (!s)
Sys_Error ("NET_FreeQSocket: not active"); Sys_Error("NET_FreeQSocket: not active");
} }
// add it to free list // add it to free list
@@ -154,121 +150,106 @@ 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);
} }
} }
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);
} }
if ((n == 1) && listening) if ((n == 1) && listening)
Cbuf_AddText ("listen 0\n"); Cbuf_AddText("listen 0\n");
if ((n > 1) && (!listening)) if ((n > 1) && (!listening))
Cbuf_AddText ("listen 1\n"); Cbuf_AddText("listen 1\n");
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;
} }
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");
} }
} }
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,23 +320,20 @@ 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)
continue; continue;
dfunc.SearchForHosts (true); dfunc.SearchForHosts(true);
} }
if ((Sys_DoubleTime() - slistStartTime) < 0.5) if ((Sys_DoubleTime() - slistStartTime) < 0.5)
@@ -375,27 +341,24 @@ 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)
continue; continue;
dfunc.SearchForHosts (false); dfunc.SearchForHosts(false);
} }
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;
} }
if (! slistSilent) if (!slistSilent)
PrintSlistTrailer(); PrintSlistTrailer();
slistInProgress = false; slistInProgress = false;
slistSilent = false; slistSilent = false;
@@ -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;
} }
@@ -445,25 +403,21 @@ qsocket_t *NET_Connect (const char *host)
} }
slistSilent = host ? true : false; slistSilent = host ? true : false;
NET_Slist_f (); NET_Slist_f();
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,17 +425,15 @@ 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);
if (ret) if (ret)
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;
@@ -535,7 +483,7 @@ void NET_Close (qsocket_t *sock)
SetNetTime(); SetNetTime();
// call the driver_Close function // call the driver_Close function
sfunc.Close (sock); sfunc.Close(sock);
NET_FreeQSocket(sock); NET_FreeQSocket(sock);
} }
@@ -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,44 +632,32 @@ 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++;
continue; continue;
@@ -757,23 +678,21 @@ NET_Init
==================== ====================
*/ */
void NET_Init (void) void NET_Init(void) {
{
int i; int i;
qsocket_t *s; qsocket_t *s;
i = COM_CheckParm ("-port"); i = COM_CheckParm("-port");
if (!i) if (!i)
i = COM_CheckParm ("-udpport"); i = COM_CheckParm("-udpport");
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
Sys_Error ("NET_Init: you must specify a number after -port"); Sys_Error("NET_Init: you must specify a number after -port");
} }
net_hostport = DEFAULTnet_hostport; net_hostport = DEFAULTnet_hostport;
@@ -785,51 +704,46 @@ 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;
s->disconnected = true; s->disconnected = true;
} }
// 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++;
net_drivers[net_driverlevel].initialized = true; net_drivers[net_driverlevel].initialized = true;
if (listening) if (listening)
net_drivers[net_driverlevel].Listen (true); net_drivers[net_driverlevel].Listen(true);
} }
/* Loop_Init() returns -1 for dedicated server case, /* Loop_Init() returns -1 for dedicated server case,
* 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();
@@ -849,14 +762,12 @@ void NET_Shutdown (void)
for (sock = net_activeSockets; sock; sock = sock->next) for (sock = net_activeSockets; sock; sock = sock->next)
NET_Close(sock); NET_Close(sock);
// //
// 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
+232 -320
View File
File diff suppressed because it is too large Load Diff
+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];
+255 -319
View File
File diff suppressed because it is too large Load Diff
+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
} }